c# - Principal Role App 引用的属性必须与 EntityType 的键完全相同

标签 c# asp.net asp.net-mvc-3 entity-framework

我首先使用 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:

http://ge.tt/3rRWTOR/v/0?c

最佳答案

在您的 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/

相关文章:

c# - +CDS AT COMMAND 问题

c# - 如何将文本框的精确值从一页传递到另一页

c# - [目录未找到异常 : Could not find a part of the path

c# - 将用户的登录方法保存在cookie中?

asp.net-mvc - ASP.NET MVC 3 Beta 1阻止对Razor View 的访问

c# - 无法将文件上传到 Google 云端硬盘

c# - gdb、mdb和软调试器的区别

c# - Code First Entity Framework 在哪里保存数据

c# - 如何将查询结果附加到数据表c#

asp.net-mvc-3 - ASP.NET MVC - 当前页面在导航中突出显示