I have a situation where I’m adding existing entities to an entity collection. Before calling “context.SaveChanges()”, I need to know which entities in the entity collection have not had their relationship saved in the database. There’s no point in checking the “EntityState” property of each entity in the collection because they are all “Unchanged” (remember, the entities already exist in the database). I should mention that the type of relationship is “many-to-many”…basically, I want to know if a row has been added to the “many-to-many” relationship table.
I have a situation where I’m adding existing entities to an entity collection. Before
Share
I’m not aware of a way to accomplish just that what you ask, but it may be of help – you can see which entities have been changed by inspecting contents of DBContext.ChangeTracker.Entries(), where every entry has reference to the changed entity object.
This collection should contain all new/modified/deleted records in any, including your many-to-many relationship table.