I\'m having some issues Seeding data and I was able to reproduce the issue with a very small application.
Given you have this Seed Method:
protected ove
No command in EF automatically updates child - AddOrUpdate
is no difference, it internally check existence of the top level entity (Junk
in your case) and insert or update it if it doesn't exist. The insertion of children is a side effect in this case because when AddOrUpdate
internally calls Add
it adds whole object tree. AddOrUpdate
does really much less magic than people expect but even with this small amount of magic it should be used only in migration seeding because it is quite expensive operation (additional roundtrip to database for every entity and a lot of reflection).
Child must always be updated separately - it may require your own separate queries to database to find correct child and common EF update.