-
-
Notifications
You must be signed in to change notification settings - Fork 99
Description
After a cursory look at the open issues, it does not look like this one has been submitted.
I have a simple model consisting of Book and Author objects. There is a many-to-many relationship between these objects. Author objects contain a collection of Book objects and properties for Id, FirstName, and LastName, all of which are required.
I am attempting to add a graph consisting of one Book (book1) object and two associated Author objects (author1 and author2) that are all new entities.
If I issue the commands:
context.UpdateGraph(book1, m => m.OwnedCollection(e => e.Authors));
context.SaveChanges();
...then no errors are generated and the resultant records are what I would expect.
The problem is that my understanding is that I should use AssociatedCollection instead of OwnedCollection as the relationship is many-to-many.
If I issue the commands:
context.UpdateGraph(book1, m => m.AssociatedCollection(e => e.Authors));
context.SaveChanges();
...then validation exceptions are thrown stating that the values for the properties FirstName and LastName (of the Author objects) are invalid (they are null). I can verify that this is true by inspecting the entities in the change tracker of the context.
Is this really an issue or is this expected behavior? If the latter, why do I need to use OwnedCollection instead of AssociatedCollection when my understanding was that I needed to or should use the latter?
Lastly, I have a sample project demonstrating this issue that I can package up and send if need be.