Synching tables with different table names

Another common question asked in the Sync Framework forums is on how to synchronize tables where the schema maybe the same but the table names are different.

For example you may have named your table on the client as ClientTable1 and simply named it Clients on the server or you may have named a table Sales on the client and named it ConsolidatedSales on the server side. Another example is where you’d like to sync your client tables to separate tables on the server side per client: Client1 – Table1, Client2 – Table1 becomes Client1Table1 and Client2Table on the server side.

Luckily, this scenario is actually supported by Sync Framework via the GlobalName property of the DbSyncTableDescription (see: However, the documentation comes up short on any examples on how to use it.

Here’s a code snippet on how to use this property:

Code Snippet
  1. //provision TestTable on 1st peer
  2. DbSyncTableDescription TableXDescription;
  4. TableXDescription= SqlSyncDescriptionBuilder.GetDescriptionForTable( "TableX", (System.Data.SqlClient.SqlConnection)provider.Connection );
  6. TableXDescription.GlobalName = "TestTable";
  9. //provision TestTable on 2nd peer
  10. DbSyncTableDescription TableYDescription;
  12. TableYDescription= SqlSyncDescriptionBuilder.GetDescriptionForTable( "TableY", (System.Data.SqlClient.SqlConnection)provider.Connection );
  14. TableYDescription.GlobalName = "TestTable";

The property essentially allows you to map the local table name to a global name that the sync topology uses. This allows Sync Framework to map back the global name to the corresponding local table name during change enumeration/application.

Hope this helps.




One comment

  1. […] Both tables are added to the scope using standard provisioning code. Since we have different table names, we assign a common name to the tables using the GlobalName property (see: Synching tables with different table names) […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: