加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – EntityFramework.dll中发生了’System.Data.Entity.I

发布时间:2020-12-16 07:06:13 所属栏目:asp.Net 来源:网络整理
导读:我映射了两个表并在MVC中创建了脚手架.单击“创建”按钮后填写表单中的数据后,会出现以下错误. An exception of type ‘System.Data.Entity.Infrastructure.DbUpdateException’ occurred in EntityFramework.dll but was not handled in user code Addition
我映射了两个表并在MVC中创建了脚手架.单击“创建”按钮后填写表单中的数据后,会出现以下错误.

An exception of type
‘System.Data.Entity.Infrastructure.DbUpdateException’ occurred in
EntityFramework.dll but was not handled in user code

Additional information: A value shared across entities or associations
is generated in more than one location. Check that mapping does not
split an EntityKey to multiple store-generated columns.

解决方法

当您具有子类型表映射,但其主键设置为自动生成时,通常会发生此问题.这是有问题的,因为EF将根据根实体的密钥显式设置值.

如果确实存在上述问题,那么要解决它,请将子表的“身份规范”设置为false.即从EDMX中删除StoreGeneratedPattern =“identity”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读