Copy Entity and children from one database to another

Posts   
 
    
dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 18-Dec-2008 15:52:53   

I am running LLBLGenPro 2.5 Final, using Visual Studio 2005 (C#). I want to figure out a cleaner way to copy entities from one database (SQL 2005 Express) to another (SQL 2005). Currently, I set the ActualConnectionString to the SQL Express database, then I fetch the entire entity graph. Then I make a copy, (I am not using the memorystream method, rather creating a new entity and copying each field one at a time). Then, I set the ActualConnectionString to the SQL 2005 database and save the entity recursively.

Is there a better way?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 18-Dec-2008 21:46:18   

Not really, no. To make the entities and the fields think that they need to be saved you either need to create new ones as you are doing at the moment, or set each entity's IsNew = true & IsDirty = true, and set each Field's IsChanged = true on your existing entity and resave that - so either way round you end up traversing the whole graph.

Matt