Используя Microsoft Framework Sync Framework Tool, я подготовил две базы данных Microsoft SQL Server (первый фрагмент кода). Затем, пытаясь синхронизировать данные в них, я запускал некоторый код из учебников MSDN, которые я настроил для своих баз данных, которые очень просты и не сложны вообще (второй фрагмент кода).Конфигурирование адаптеров в инфраструктуре синхронизации
Моя проблема заключается в том, что при запуске синхронизации кода, я получаю сообщение об ошибке:
Cannot apply changes because the local provider does not have adapters configured for the following tables that were received from the remote provider: Spray_History. Ensure that the correct adapters have been added to both providers for Scope 'SprayHistory_SCOPE', and that any table mapping has been correctly configured.
Я также включать в себя некоторые фрагменты таблиц базы данных, чтобы показать, что предоставление сервера, кажется, пошли успешно ,
Сервер Provisioning
//Create a connection to the DustSuppression database (the Catalog name here changes for each database)
SqlConnection sqlConnection = new SqlConnection("Data Source = TKTEST-2; Initial Catalog = Dust_Suppression; Integrated Security = SSPI");
//Create a sync scope for SprayHistory table in database (we can name it whatever we want when we create it)
DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("SprayHistory_SCOPE");
//Specify name of sync scope and list of tables to be synced (this needs to be the actual table name & server connection)
DbSyncTableDescription tableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable("Spray_History", sqlConnection);
//Add the table description to the scope description
scopeDesc.Tables.Add(tableDesc);
//Provision the database with sync related artifacts (create provision object using scope description & server connection)
SqlSyncScopeProvisioning serverProvision = new SqlSyncScopeProvisioning(sqlConnection, scopeDesc);
//Since the SprayHistory table already exists, inform the sync tool to skip creating it
serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip);
//Start the provisioning
serverProvision.Apply();
синхронизации данных между серверами
static void Main(string[] args)
{
//Connection string to the client (assume this to be S2)(this would normally be an ExpressDB)
SqlConnection clientConnection = new SqlConnection("Data Source=TKTEST-2;Initial Catalog=Dust_Suppression;Integrated Security=SSPI");
//Connection string to the database (assume this to be S1)(this would be the normal SQL DB)
SqlConnection serverConnection = new SqlConnection("Data Source=TKTEST-2;Initial Catalog=DustSuppression;Integrated Security=SSPI");
//Create a sync orchestrator
SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
//Set local provider of orchestrator to a sync provider (S2)(this would normally be an ExpressDB)
syncOrchestrator.LocalProvider = new SqlSyncProvider("SprayHistory_SCOPE", clientConnection);
//Set remote provider of orchestrator to a server sync provider (S1)(this would be the normal SQL DB)
syncOrchestrator.RemoteProvider = new SqlSyncProvider("SprayHistory_SCOPE", serverConnection);
//Set the direction of sync session to UPload and Download
syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
//Subscribe for errors that occur when applying changes to the client
((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
//Execute the synchronization process
SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
// print statistics
Console.WriteLine("Start Time: " + syncStats.SyncStartTime);
Console.WriteLine("Total Changes Uploaded: " + syncStats.UploadChangesTotal);
Console.WriteLine("Total Changes Downloaded: " + syncStats.DownloadChangesTotal);
Console.WriteLine("Complete Time: " + syncStats.SyncEndTime);
Console.WriteLine(String.Empty);
}
static void Program_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)
{
// display conflict type
Console.WriteLine(e.Conflict.Type);
// display error message
Console.WriteLine(e.Error);
}
ВСС Отрывки