New Posts New Posts RSS Feed: Copying/Cloning models between SQL Instances
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Copying/Cloning models between SQL Instances

 Post Reply Post Reply
Author
PJones View Drop Down
Newbie
Newbie
Avatar

Joined: 10-Oct-2007
Location: United States
Posts: 10
Post Options Post Options   Quote PJones Quote  Post ReplyReply Direct Link To This Post Topic: Copying/Cloning models between SQL Instances
    Posted: 11-Dec-2007 at 10:30am
I have a need to read an object model from one SQL (remote) database and persist that model to another SQL (local) database.  I also need to be able to push the local DB info back to the remote.
 
Are there any built-in features and/or best practices for accomplishing this?
 
 
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 12-Dec-2007 at 8:34am
Here is some sample code for cloning.  It handles such problems as:
 
o A cloned object cannot have a primary key identical to the object from which it is being cloned.
o Handling of foreign keys
 
Back to Top
PJones View Drop Down
Newbie
Newbie
Avatar

Joined: 10-Oct-2007
Location: United States
Posts: 10
Post Options Post Options   Quote PJones Quote  Post ReplyReply Direct Link To This Post Posted: 13-Dec-2007 at 9:35am
I have this same code sample (from tech support) already.
 
When you say "handles" foreign keys what do you mean?
 
What I want is the object and its entire dependent tree including all data in all child objects cloned.  This code only clones the target object and skips all relations downward and makes an exact copy of foreign key values which will not always work (ie. if I clone a patternCollection child of a Project class I don't want it to be the child of Project 1 (cloned) but the child of the newly created (cloned) Project object).
 
Pete
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 14-Mar-2008 at 11:15am
Has this been resolved. I am wanting the same thing. A clone of the object and all of it's references.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down