0

我有两个完全相同的数据库表,一个 prod 和一个 dev。每当我部署到开发数据库时,一切正常。prod 数据库允许我尝试使用 EF 和 MVC 将数据写回数据库时引发此错误。

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 代码没有问题,纯粹是 db 表问题无论如何我可以找到更多详细信息吗?

4

1 回答 1

0

在 EF4 中删除外键关系关于该问题的好文章 http://blogs.msdn.com/b/dsimmons/archive/2010/01/31/deleting-foreign-key-relationships-in-ef4.aspx

于 2013-04-04T14:19:09.137 回答