Moving entities between contexts in .NET Entity Framework 3.5 -


I have found a scenario in which I want to move a group of object graphs between references. In particular, I am trying to import the content of a database into another. There is a reference related to primary DB [currentcontactx], and the second reference [importcontext] is connected to another DB. I want to copy the copy of the institutions from the ImportsContact to the currentcontact, either entering new records or updating existing records.

ImportContext.Organization.MergeOption = MergeOption.No tracking; Foreign Currency (Various Organizations in ImportContext. Talkal ()) {CurrentContext.Attach (org); // or CurrentContext.AddToOrganization (org); }

When I try the Attach method, the organization is not saved because the units are unchanged, and I do not understand how to mark it in a new form. In addition, it appears that if the entity is new, then attachments do not work because EntityKey is connected to ImportContext. If I have set EntityKey to clear, I lose associations between organization and other institutions. With the loss of organizations, there is only one problem of AddToOrganization, or if the organization is already in CurrentContext it will fail.

What is the proper approach to this kind of import? I am currently using EF3.5 and can not update the project to EF4.

  1. separate the unit from a different reference
  2. AddObject unit in new context.

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -