I have two entities connected via one-to-many relationship: Computer entity has many Instances. I'm trying to develop simple undo/redo mechanism for my appliation.
Redo for DeleteComputerAction just removes computer instance from Entity Framework context (it also clears computer's Instances collection). But when I want to Undo this change by
((IObjectContextAdapter)_dbContext).ObjectContext.Refresh(RefreshMode.StoreWins, computer.Instances);
_dbContext.Entry(computer).Collection(e => e.Instances).Load();
nothing happens. May be EF caches the data I want to reload? How can I force to reaload computer.Instances collection from the DB?
EDIT
Actually I have no changes in my DB. I just mark computer entity as deleted in EF context and then immediately try to restore its state form DB. When I delete computer entry from EF context its .Instances collection becomes empty. I just need to automatic repopulate it from DB and that is all.