我有一个应用程序在两个数据库之间进行同步:中央服务器托管在Sql Server 2008上,本地服务器是Sql Compact 3.5数据库。Sql Compact 3.5同步失败
有时我需要升级包含在同步范围内的一个表的模式,我不想再取消配置和提供,所以我使用了this方法和Sql Compact我有类似这样的东西:
public void UpdateProvisionSchema(string connString, string scopeName, string newConfigData)
{
_log.Verbose("UpdateProvisionSchema: " + scopeName);
try
{
string query = string.Format("SELECT [scope_config_id] FROM [scope_info] WHERE [sync_scope_name]='{0}'", scopeName);
Guid config_id = (Guid)SqlCompactManager.ExecuteScalar(connString, query);
string updateCommand = string.Format("UPDATE scope_config SET [config_data]='{0}' WHERE [config_id] ='{1}'", newConfigData, config_id);
SqlCompactManager.ExecuteCommand(connString, updateCommand);
}
catch (Exception ex)
{
_log.Error(ex, string.Format("Failed to upgrade schema for scope {0}", scopeName));
throw new Exception(string.Format("Update of provisioned schema failed for scope: {0}", scopeName));
}
}
我手动更改我的表的配置范围。我认为我发送的范围配置是正确的,因为我通过配置一个空表来生成它。
我刚刚添加一列到同步作用域中包含的表(其数据只从中央数据库下载到本地数据库),现在我在ApplyChangeFailed上收到一个错误。
看来,在Sql Compact数据库中,包含在同步作用域中的表所包含的表具有以下列:__sysTrackingContext在中央表中不存在。
第一次我创建了表并设置了它们,然后我添加了2个新列(BusinessType,HideCommentAndSerialNumber)。如果我看DbApplyChangeFailedEventArgs并检查专栏中,我看到以下内容:
中央:
.. |商业类型| HideCommentAndSerialNumber | sync_update_peer_timestamp | sync_update_peer_key | sync_create_peer_timestamp | sync_create_peer_key |
本地:
.. | __sysTrackingContext |商业类型| sync_update_peer_key | HideCommentAndSerialNumber | sync_update_peer_timestamp | sync_create_peer_key | sync_create_peer_timestamp |
我在做什么错?