我首先使用 EF DB。
我做了一个观点。
将其映射到 EF。
现在我得到以下错误:
Error 2 Error 111: Properties referred by the Principal Role App must be exactly identical to the key of the EntityType MaMDBModel.App referred to by the Principal Role in the relationship constraint for Relationship MaMDBModel.FK_AppsData_App. Make sure all the key properties are specified in the Principal Role. D:\MaM\Dev\MamAdmin_1.0\MaMDBEntityFramework\MaMModel.edmx 768 11 MaMDBEntityFramework
这是我的 edmx:
最佳答案
在您的 edmx 文件中有一条错误消息作为注释:
<!--Errors Found During Generation:
warning 6002: The table/view 'MamDB.dbo.VW_APPSDATA' does not have a primary key
defined. The key has been inferred and the definition was created as a read-only
table/view.
-->
EF 推断出的 key 可能是错误的。根据消息,您应该为数据库中的 View 定义一个主键。
关于c# - Principal Role App 引用的属性必须与 EntityType 的键完全相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13331531/