gpt4 book ai didi

c# - Entity Framework 错误 "Entity type is not mapped."

转载 作者:可可西里 更新时间:2023-11-01 02:59:11 27 4
gpt4 key购买 nike

我们在项目中使用 Entity Framework,我在模型中构建了一个实体。然后我有一个使用存储过程的函数导入。函数导入创建的方法应该返回我创建的自定义实体的集合。

The problem is that I get an error when I build that says "The entity type 'someentity' is not mapped.

这是什么意思?是否因为实体没有底层数据存储而感到沮丧?它不需要一个,函数导入返回此实体的实例,我不需要更新、编辑或插入此类型的实体。

函数 import 工作得很好,并根据需要返回我的实体的集合,但这个错误很烦人。尽管错误列表将其列为编译错误,但它实际上并没有阻止解决方案的编译。

更新

如果我在 XML 编辑器中打开 EDMX 并双击错误列表中的错误,它会以红色突出显示此 XML block :

   <EntityContainerMapping StorageEntityContainer="KlasEntitiesStoreContainer" CdmEntityContainer="KlasEntities">
<EntitySetMapping Name="VendorBriefs"><EntityTypeMapping TypeName="KlasEntityDataModel.VendorBrief"><MappingFragment StoreEntitySet="ev_VendorBriefs">
<ScalarProperty Name="VendorBriefID" ColumnName="VendorBriefID" />
<ScalarProperty Name="Title" ColumnName="Title" />
<ScalarProperty Name="Link" ColumnName="Link" />
<ScalarProperty Name="LinkText" ColumnName="LinkText" />
<ScalarProperty Name="BriefPath" ColumnName="BriefPath" />
<ScalarProperty Name="Description" ColumnName="Description" />
<ScalarProperty Name="IsActive" ColumnName="IsActive" />
<ScalarProperty Name="DisplayOrder" ColumnName="DisplayOrder" />
</MappingFragment></EntityTypeMapping></EntitySetMapping>
<FunctionImportMapping FunctionImportName="SearchForVendorProductByKlasID" FunctionName="KlasEntities.Store.ev_ds_Products_SearchByKLASID" />
</EntityContainerMapping>

最佳答案

每个实体都必须映射到 QueryView 或数据库表/定义查询。您无法创建根本未映射的实体。如果要定义未映射到模型中的函数导入结果,则必须将 VendorBrief 定义为复杂类型。

关于c# - Entity Framework 错误 "Entity type is not mapped.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5737675/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com