I've finally got the motivation to have another crack at using multiple entity managers in my application. I've managed to get it to work for editing an entity but having problems with adding a new entity.
I have a grid displaying a list of entities (lets say orders for an employee). When I go to add a new entity these are the steps I'm going through. I have an issue at step 5
1) Create a new entity
_mgr.CreateEntity<Order>();
2) Create the new entity manager and copy this new item over
var mgr2 = new MyEntities();
mgr2.LinkForAuthentication(this);
mgr2.EntityChanged += (s, args) => { if (args.Action == EntityAction.Delete) { _mgr.RemoveEntity(args.Entity); } };
mgr2.ImportEntities(new Entity[] { root }, MergeStrategy.OverwriteChanges);
3) Make changes to this entity and save it
4) I copy the new entity back into the main entity manager
_Mgr.ImportEntities(this.FindEntities(EntityState.Added | EntityState.Deleted | EntityState.Modified), MergeStrategy.OverwriteChanges);
5) The problem I have is at this point I would normally add to the new Entity to RelatedEntityList to make the order appear for that employee. BUT how do I get a reference to the newly imported entity?