eyeballpaul
eyeballpaul

Reputation: 1735

Entity Framework Self Tracking Entities - Synchronize between 2 databases

I am using Self Tracking Entities with the Entity Framework 4. I have 2 databases, with the exact same schema. However, tables in one database will be added to/edited etc (and I mean data will be added/edited, not the actual table definitions) and at certain points of the day I will need to synchronize all the changes between this database and the other database.

I can create a separate context for both of them. But if I read a large graph from one database, how can I update the other database with the graph? Is there an easy way?

My database model is large and complex and fully relational. So it would be a big job to go through every single entity and do a read from the other database to see if it exists or not, update/insert it if need be, and then carry this on through the full object graph!

Any ideas?

Upvotes: 1

Views: 369

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364279

This is not a use case for EF. In EF you will have to do exactly what you've described. Self tracking entities are able to track changes to these object instances - they know nothing about changes made to their own database over time and they will not know anything about state of your second database as well.

Try to look at SQL server native features (including mirroring, transaction log shipping or SSIS) and MS Sync framework. Depending on your detailed requirements these tools can suite you better.

Upvotes: 2

Related Questions