The relationship could not be changed because one or more of the foreign-key properties is non-nullable

Today’s cryptic Entity Framework message …

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.

The reason for this was a simple override to GetHashCode(). Entity Framework seems somewhat pedantic about how hash codes work.



Mon May 10 2010 06:35:24 GMT-0700 (Pacific Daylight Time)


Next page: Hybrid Ontology + Relational Store with SQL Server

Previous page: Why functional programming and LINQ is often better than procedural code


Disqus goes here