Answered by:
Peer-2-Peer Table Mapping -- Is it *possible*??

Question
-
I have a working peer-2-peer sync app that syncs several tables between 2 SQL Server databases (both on 2008 server). One table is called Countries and has only a few columns. I sync this between my 2 peers setting up the providers with the following code:
DbSyncTableDescription CountriesTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable( "Countries", (System.Data.SqlClient.SqlConnection)provider.Connection );
scopeDesc.Tables.Add( CountriesTableDescription );
The rest of the code is right from the sample app. Everything works find and these tables synchronize changes as expected.
Now I simply create a new table called Countries_Version on peer1 which is an *exact*t copy of the original Countries table.
I want to now sync Countries_Version on peer1 with Countries on peer2; I alter the code as follows when configuring my
providers:
DbSyncTableDescription CountriesTableDescription;
if (provider.Connection.Database.ToLower() == "peer1")
{
CountriesTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable( "Countries_Version", (System.Data.SqlClient.SqlConnection)provider.Connection );
// map to the Countries table on peer2
CountriesTableDescription.GlobalName = "Countries";
}
else
{
CountriesTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable( "Countries", (System.Data.SqlClient.SqlConnection)provider.Connection );
// map to the Countries_Version table on peer2
CountriesTableDescription.GlobalName = "Countries_Version";
}
Note: I use one method to configure my providers and pass “peer1” or “peer2” along with the additional
database connection parameters required. Countries has a single column PK on a bigit identity type and Countries_Version
has the identical set-up. Both tables have an identical set of additional columns – both tables identical other than the table names.
When attempting to first synchronize the two databases , on the call:
SyncOperationStatistics stats = orchestrator.Synchronize();
I get the following error:
Microsoft.Synchronization.Data.DbSyncException: Cannot apply changes because the local provider does not have adapters configured for the following tables that were received from the remote provider: Countries. Ensure that the correct adapters have been added to both providers for scope ‘test_scope’ and that any table mapping has been properly configured.
And, of course, the synchronization fails.
I am trying to create the simplest demo imaginable to demonstrate table mapping between 2 differently named tables for a sync operation. An MS developer has indicated to me previously that all I need to do is set the GlobalName on the DbSyncTableDescription object. I think I am doing that, as demonstrated in the above code. But I just can’t seem to get any table mapping sync to work.
Can anyone shed some light on what I am doing wrong here?? I’ve been tinkering with this for hours now, and it seems that it just shouldn’t be this difficult to map 2 tables in a synchronization. I’ve scoured the MS ADO.NET Sync 2.0 documentation, but it is virtually devoid of any real help on how to map 2 tables or shed any light whatsoever on how to use GlobalName or LocalName properties.
Thanks,
Glenn
Monday, May 17, 2010 4:10 PM
Answers
-
Hi,
For both peers, you should pick the same value for the GlobalName. Please try to change your get table description code to below and see if it works:
DbSyncTableDescription CountriesTableDescription;
if (provider.Connection.Database.ToLower() == "peer1")
{
CountriesTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable( "Countries_Version", (System.Data.SqlClient.SqlConnection)provider.Connection );
}
else
{
CountriesTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable( "Countries", (System.Data.SqlClient.SqlConnection)provider.Connection );
// map to the Countries_Version table on peer2
CountriesTableDescription.GlobalName = "Countries";
One more thing to remember is that the SqlSyncProvisioning only provides table mapping but no column mapping yet.
Thanks,
Dong
This posting is provided AS IS with no warranties, and confers no rights.- Proposed as answer by Dong CaoMicrosoft employee Monday, May 17, 2010 6:59 PM
- Marked as answer by Dong CaoMicrosoft employee Monday, May 17, 2010 8:54 PM
Monday, May 17, 2010 6:58 PM
All replies
-
Hi,
For both peers, you should pick the same value for the GlobalName. Please try to change your get table description code to below and see if it works:
DbSyncTableDescription CountriesTableDescription;
if (provider.Connection.Database.ToLower() == "peer1")
{
CountriesTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable( "Countries_Version", (System.Data.SqlClient.SqlConnection)provider.Connection );
}
else
{
CountriesTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable( "Countries", (System.Data.SqlClient.SqlConnection)provider.Connection );
// map to the Countries_Version table on peer2
CountriesTableDescription.GlobalName = "Countries";
One more thing to remember is that the SqlSyncProvisioning only provides table mapping but no column mapping yet.
Thanks,
Dong
This posting is provided AS IS with no warranties, and confers no rights.- Proposed as answer by Dong CaoMicrosoft employee Monday, May 17, 2010 6:59 PM
- Marked as answer by Dong CaoMicrosoft employee Monday, May 17, 2010 8:54 PM
Monday, May 17, 2010 6:58 PM -
Yes, that works. I misunderstood how the GlobalName property is to be used - I thought originally that if the table on the other end of the sync was named differently, then the GlobalName prop had to be set to that name to properly map, but instead I see it's a shared name that both ends of the sync agree is to be used to map the sync tables. I wish this sort of information was clear in the MS Sync Services documentation.
Thanks,
Glenn
Monday, May 17, 2010 8:40 PM