0

我正在尝试同步以下两个表。

在目标数据库中,ParentTable 无法更新或删除;但是,ChildTable 可以正确同步。

我错过了什么吗?预先感谢!

在此处输入图像描述

DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("Name");

scopeDesc.Tables.Add(SqlSyncDescriptionBuilder.GetDescriptionForTable("ParentTable", sqlSourceConn));
scopeDesc.Tables.Add(SqlSyncDescriptionBuilder.GetDescriptionForTable("ChildTable", sqlSourceConn));


var sqlSourceProv = new SqlSyncScopeProvisioning(sqlSourceConn, scopeDesc);
sqlSourceProv.CommandTimeout = 3600;
if (!sqlSourceProv.ScopeExists("Name"))
   sqlSourceProv.Apply();

var sqlDestinationProv = new SqlSyncScopeProvisioning(sqlDestinationConn, scopeDesc);
sqlDestinationProv.CommandTimeout = 3600;
if (!sqlDestinationProv.ScopeExists("Name"))
   sqlDestinationProv.Apply();

var destinationProvider = new SqlSyncProvider("Name", sqlDestinationConn);

var sourceProvider = new SqlSyncProvider("Name", sqlSourceConn);

destinationProvider.MemoryDataCacheSize = MemorySize;
sourceProvider.MemoryDataCacheSize = MemorySize;

destinationProvider.ApplicationTransactionSize = BatchSize;

SyncOrchestrator orch = new SyncOrchestrator();
orch.RemoteProvider = destinationProvider;
orch.LocalProvider = sourceProvider;
orch.Direction = SyncDirectionOrder.Upload;

SyncOperationStatistics stats = orch.Synchronize();
4

1 回答 1

1

如果您有 FK 关系,则它必须在冲突期间引发错误(无法删除带有孩子的父母)...您可以通过订阅 ApplyChangeFailedEvent 来验证这一点。您可以设置冲突解决来解决问题。

于 2012-05-16T23:55:46.010 回答