I am uploading a sample solution that shows how to import entities from one PM to another. The sample solution uses two different SQL Server databases, and the application saves all changes to both databases
The sample solution uses a feature of DevForce called Data Source Extension. When you use a Data Source Extension. you can use two PersistenceManagers each associated with the same schema, but having a different connection string.
Here are the two RdbKeys:
.....
Open the first PersistenceManager normally.
mPM = PersistenceManager.DefaultManager;
mEmployees = mPM.GetEntities<Employee>();
Open the second PersistenceManager using the Data Extension signature:
mPmLegacy = new PersistenceManager(true, "Legacy");
Here is the 3 line snippet:
private void SaveToLegacyDB() {
mPmLegacy = new PersistenceManager(true, "Legacy");
mPmLegacy.ImportEntities(mPM.GetEntities<Employee>(DataRowState.Modified | DataRowState.Added | DataRowState.Deleted), MergeStrategy.PreserveChanges);
mPmLegacy.SaveChanges();
}