Microsoft同步默认架构不存在

时间:2014-10-17 15:53:02

标签: c# microsoft-sync-framework

我使用Microsoft同步框架在远程和本地数据库之间同步数据,但我面临错误 在远程服务器上应用配置时,“默认架构不存在”

SqlSyncProvider sqlProviderLocal = new SqlSyncProvider(scopeName,sqlConnLocal);                 SqlSyncProvider sqlProviderRemote = new SqlSyncProvider(scopeName,sqlConnRemote);

            SqlSyncScopeProvisioning scopeProvisionLocal = new SqlSyncScopeProvisioning(sqlConnLocal);
            scopeProvisionLocal.ObjectSchema = ".dbo";
            if (!scopeProvisionLocal.ScopeExists(scopeName))
            {
                DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription(scopeName);

                foreach (var item in Tables)
                {
                    scopeDesc.Tables.Add(SqlSyncDescriptionBuilder.GetDescriptionForTable(item, sqlConnLocal));
                }

                scopeProvisionLocal.PopulateFromScopeDescription(scopeDesc);
                scopeProvisionLocal.SetCreateTableDefault(DbSyncCreationOption.Skip);
                scopeProvisionLocal.Apply();
            }

            SqlSyncScopeProvisioning scopeProvisionRemote = new SqlSyncScopeProvisioning(sqlConnRemote);
            scopeProvisionRemote.ObjectSchema = ".dbo"; 
            if (!scopeProvisionRemote.ScopeExists(scopeName))
            {
                DbSyncScopeDescription scopeDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope(scopeName, sqlConnLocal);
                scopeProvisionRemote.PopulateFromScopeDescription(scopeDesc);
                scopeProvisionRemote.Apply();
            }

            agent.LocalProvider = sqlProviderLocal;
            agent.RemoteProvider = sqlProviderRemote;
            SyncOperationStatistics stats = agent.Synchronize();

            result = ClearExtras();

            sqlConnLocal.Close();
            sqlConnRemote.Close();

0 个答案:

没有答案