Is there a demo that shows how to implement multiple entity managers?
I am really struggling to get the multiple entity manager working. I've been working off the code posted at http://drc.ideablade.com/xwiki/bin/view/Documentation/SavingBusinessObjects#HDependencyGraphRetrieval
However, I'm not sure how to implement the step that says
"After save, the application might export the saved rep back into the main EM
where it now displays in the grid in its post-save glory."
It seems when I call SaveChangesAsync on the second entity model it is not being committed to the database. So I basically used the dependency graph retrieval in reverse to get the models back into the main EM. Some issues I have found are
1) The dependency graph is not picking up items which are still being loaded asynchronously
3) Doesn't like many to many relationships. I get this error when trying to save
{EntityManagerSaveException: The object being attached to the source object is not attached to the same ObjectContext as the source object. ---> System.InvalidOperationException: The object being attached to the source object is not attached to the same ObjectContext as the source object.
at System.Data.Objects.DataClasses.RelatedEnd.ValidateEntityForAttach(IEntityWrapper wrappedEntity, Int32 index, Boolean allowCollection)
at System.Data.Objects.DataClasses.RelatedEnd.Attach(IEnumerable`1 wrappedEntities, Boolean allowCollection)
at System.Data.Objects.DataClasses.RelatedEnd.System.Data.Objects.DataClasses.IRelatedEnd.Attach(Object entity)
at IdeaBlade.EntityModel.Edm.EdmSaveHelper.ProcessManyToMany(List`1 entities)
at IdeaBlade.EntityModel.Edm.EdmSaveHelper.ProcessSaves(IEnumerable`1 groupsByType)
at IdeaBlade.EntityModel.Edm.EdmSaveHelper.SaveWithinContext()
at IdeaBlade.EntityModel.Edm.EdmSaveHelper.Save()
at IdeaBlade.EntityModel.EntityManager.HandleEntityServerException(Exception pException, Boolean pTryToHandle, PersistenceOperation pOperation)
at IdeaBlade.EntityModel.EntityManager.HandleSaveResultException(SaveWorkState saveWorkState, Boolean isAsyncOp)}
[IdeaBlade.EntityModel.EntityManagerSaveException]: {EntityManagerSaveException: The object being attached to the source object is not attached to the same ObjectContext as the source object. ---> System.InvalidOperationException: The object being attached to the source object is not attached to the same ObjectContext as the source object.
at System.Data.Objects.DataClasses.RelatedEnd.ValidateEntityForAttach(IEntityWrapper wrappedEntity, Int32 index, Boolean allowCollection)
at System.Data.Objects.DataClasses.RelatedEnd.Attach(IEnumerable`1 wrappedEntities, Boolean allowCollection)
at System.Data.Objects.DataClasses.RelatedEnd.System.Data.Objects.DataClasses.IRelatedEnd.Attach(Object entity)
at IdeaBlade.EntityModel.Edm.EdmSaveHelper.ProcessManyToMany(List`1 entities)
at IdeaBlade.EntityModel.Edm.EdmSaveHelper.ProcessSaves(IEnumerable`1 groupsByType)
at IdeaBlade.EntityModel.Edm.EdmSaveHelper.SaveWithinContext()
at IdeaBlade.EntityModel.Edm.EdmSaveHelper.Save()
at IdeaBlade.EntityModel.EntityManager.HandleEntityServerException(Exception pException, Boolean pTryToHandle, PersistenceOperation pOperation)
at IdeaBlade.EntityModel.EntityManager.HandleSaveResultException(SaveWorkState saveWorkState, Boolean isAsyncOp)}
Data: {System.Collections.ListDictionaryInternal}
InnerException: null
Message: "The object being attached to the source object is not attached to the same ObjectContext as the source object."
StackTrace: " at IdeaBlade.EntityModel.EntityManager.HandleEntityServerException(Exception pException, Boolean pTryToHandle, PersistenceOperation pOperation)\r\n at IdeaBlade.EntityModel.EntityManager.HandleSaveResultException(SaveWorkState saveWorkState, Boolean isAsyncOp)"