首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EF外键属性不可为空

EF外键属性不可为空
EN

Stack Overflow用户
提问于 2013-04-04 17:50:45
回答 1查看 1.3K关注 0票数 0

我有两个完全相同的数据库表,一个是prod,一个是dev。每当我部署到dev数据库时,一切都运行得很好。prod数据库允许我抛出这个错误,因为我尝试使用EF和MVC将数据写回数据库。

代码语言:javascript
复制
System.InvalidOperationException: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.
   at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
   at System.Data.Entity.Internal.InternalContext.SaveChanges()

当然,我已经检查过这个http://blogs.msdn.com/b/dsimmons/archive/2010/01/31/deleting-foreign-key-relationships-in-ef4.aspx

看起来我的EF代码没有问题,纯粹的数据库表问题,我可以找到更多的细节?

EN

回答 1

Stack Overflow用户

发布于 2013-04-04 22:19:09

issue http://blogs.msdn.com/b/dsimmons/archive/2010/01/31/deleting-foreign-key-relationships-in-ef4.aspx上的一篇很好的文章《在EF4中删除外键关系》

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15807890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档