Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Edited Unassigned: EF Code-First doesn't detect multiplicity constraint violation [1257]

$
0
0
In the model (self-referencing one-to-many relationship and TPH) described in this Stackoverflow question - http://stackoverflow.com/questions/17109540/entity-framework-self-referencing-entity - EF doesn't seem to recognize that the mapping is invalid with respect to multiplicity. It passes model and database creation (with the key property as the foreign key but a collection as navigation property and without creating a foreign key constraint in the database) and throws an exception later when working with the model. The exception doesn't indicate where the problem is and makes it hard to find the real reason.

Reproduced with EF 5.0 and .NET 4.0 (I've removed the Groups collection in order to make it compile)

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>