Print Page | Close Window

EF ImportEntities - Broken ?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1126
Printed Date: 19-Sep-2025 at 11:02am


Topic: EF ImportEntities - Broken ?
Posted By: smi-mark
Subject: EF ImportEntities - Broken ?
Date 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




Replies:
Posted By: kimj
Date 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". 



Print Page | Close Window