我有两个完全相同的数据库表,一个是prod,一个是dev。每当我部署到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代码没有问题,纯粹的数据库表问题,我可以找到更多的细节?
发布于 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中删除外键关系》
https://stackoverflow.com/questions/15807890
复制相似问题