PerformPostRestoreFixup()方法给出异常:Microsoft.Synchronization.Data.DbNotProvisionedException

时间:2017-02-05 12:38:11

标签: sql-server synchronization wcf-data-services change-tracking

以下是我的代码:

SqlConnection.ClearPool(serverConn);
serverConn = new SqlConnection(Utility.ConnStr_SqlSync_Server);
SqlSyncStoreRestore databaseRestore = new SqlSyncStoreRestore(serverConn);
databaseRestore.CommandTimeout = 1000; //Database is about 300 Gb
databaseRestore.PerformPostRestoreFixup(); //line #31

错误讯息:

Unhandled Exception: Microsoft.Synchronization.Data.DbNotProvisionedException: The current operation could not be completed because the database is not provisioned for sync or you not have permissions to the sync configuration tables.
   at Microsoft.Synchronization.Data.SqlServer.SqlManagementUtils.VerifyRuntimeAndSchemaVersionsMatch(SqlConnection connection, SqlTransaction trans, String objectPrefix, String objectSchema, Boolean throwWhenNotProvisioned)
   at Microsoft.Synchronization.Data.SqlServer.SqlSyncStoreRestore.PerformPostRestoreFixup()
   at FixSyncEnabledDbAfterBackup.Program.Main(String[] args) ..\Visual Studio 2010\Projects\FixSyncEnabledDbAfterBackup\FixSyncEnabledDbAfterBackup\Program.cs:line 31 

我的问题:

我如何知道是否有许可或提供问题?

我在两个具有相同结果的类似系统上运行此代码。一个系统完美同步,另一个系统在跟踪日志中提供以下警告

System.ArgumentException: SQL Server Change Tracking is not enabled for table 'Users' and stops. 

我已检查更改跟踪已启用。通过PerformPostRestoreFixup()方法,我希望在切换到简单恢复模型并回到完整模型(我认为可能导致同步问题)之后恢复第二个系统的数据库。

1 个答案:

答案 0 :(得分:0)

正如错误消息所示,这不是为表启用更改跟踪的问题。查看更改跟踪信息的权限应为同步数据的进程添加。可以在SSMS中的表属性中进行检查。