New Posts New Posts RSS Feed: EF ImportEntities - Broken ?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EF ImportEntities - Broken ?

 Post Reply Post Reply
Author
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Topic: EF ImportEntities - Broken ?
    Posted: 10-Mar-2009 at 12:09pm
Hi,

I'm working on a WPF application and I would like to be able to use multiple EntityManagers but I can't seem to get it to work properly.

Here is some code I was trying:

        Dim list As New List(Of Entity)
        list.Add(entity)

        TryCast(Application.Current, Application).Manager.Tag = "Main Manager"

        mManager = New DomainModelEntityManager(TryCast(Application.Current, Application).Manager)
        mManager.Tag = "New Manager"

        Debug.Print(entity.EntityAspect.EntityManager.Tag) ' This returns "Main Manager" as it should

        mManager.ImportEntities(list, MergeStrategy.OverwriteChanges)

        Debug.Print(entity.EntityAspect.EntityManager.Tag)
'This still returns "Main Manager" instead of "New Manager"

Is there something I'm doing wrong? I've tried a few different ways but it still won't switch the manager (I modified properties on the entity and the .HasChanges still remained false on the new manager)

Thanks,

Mark

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 16-Mar-2009 at 12:15pm
ImportEntities essentially creates a clone of the entities in an EntityManager.  Once you've run ImportEntities, "entity" still exists in "Main Manager", and a clone, with the same entity state as the original, now exists in "New Manager". 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down