我正在尝试同步以下两个表。
在目标数据库中,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();