Click here to Skip to main content
15,037,168 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)

can anyone tell me an approach to perform data synchronization from two different data models using WCF services.

Requirement is as follows:
Data model-A has entity framework generated objects which needs to be mapped with the external Data model-B.

For example:
Data model - A: has X1,X2,X3... tables that are associated with each other.
Data model - B: has Y1,Y2,Y3... tables that are associated with each other.

let us assume X1 - Table has 5 columns with name A1,A2,A3,A4,A5 (A5 itself may be an enity).
Y1 - Table has 3 columns with name B1,B2,B3.

I need to update B1,B2 values in A4,A5 of X1. here it will be like B1-A4 is one-to-one mapping,
where as B2-A5 is one-to-many mapping.

My approach of implementation is:
Find methods in Entity Framework to define entity objects of the data model-B which is exposed through OData interface, which has to be mapped with data model-A.

Create SQL database table in the destination system out of the OData interface.
Convert this data table as entity objects through the Entity Framework.
Define the mapping with the Entity framework tool to map it with data model-A and save the mapping file.
Integration service has to read this mapping file and do the sync-up using entity frame work APIs.

Please let me know if there is any better approach and sample example is needed as well.
Updated 5-Jun-14 20:19pm
Suvabrata Roy 6-Jun-14 1:51am
1. what is the data volume you have? 6-Jun-14 1:59am
Hi Roy, since its in server, sorry i m not aware of volume. 6-Jun-14 2:08am
Are there any methods in Entity Framework to define entity objects of the data model-B which is exposed through OData interface, which has to be mapped with data model-A.

1 solution

Ok, Now I assume that its a database near about 5 GB and increment on regular basis about 0.09%.

I also assume that its reside on remote that mean two databases cant talk directly.

Few prerequisites :

Each Table you need to synchronize they should have one primary key.

Using WCF

1. Create One Table in another database which we will use as a witness, the table will contain few columns like Role Id,DB Id,DB Name, Role,Table Name, Sync Group name,Type (Push/Pull).
Another table with Mapping, columns are Role Id,Column Name,Alias Name, IsActive
Another Table with synchronized Details Role Id,Counter,Date

2. Create two WCF services One for pulling data and another for pushing data.
3. First service will first pick the max counter from synchronized details then pull incremental data from there server depending on mapping connection string will resides on server with the name Role Id but its should be encrypted and there should be a default connection string which will connect witness server.
4. First service will pull the data from server and serialize it with a key ( which will be generated at run time Unique) and notify the User/WCF (as required)
5. Second service will push the as notify with the key and read from the derive and insert or update or delete data depending data state. That serialize data will have role id and incremental id of depending synchronization table.
6. when sync will complete second service will update synchronized details table with the counter.

If you have any query feel free to ask me,
Comments 6-Jun-14 2:40am
Thanks Roy, It would be very kind of you if you provide me a source code for this approach.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900