微软同步框架。应用“范围”到现有的 SqlCe 数据库
是否可以将 DbSyncScopeDescription 应用于现有的 SqlCeDatabase?
我正在尝试使用从该数据库构建的 DbSyncScopeDescription 来配置现有数据库。
这是我用来测试这个的代码。这应该能让您了解我正在尝试做什么。
我在最后一行收到 SqlCeException 并显示消息:
“指定的索引不存在。[ sysChangeTxBsn_idx ]”。
private void Test()
{
DbSyncScopeDescription scopeDescription =
new DbSyncScopeDescription("MyScope");
foreach (string tableName in TableNames)
{
DbSyncTableDescription tableDecsription = SqlCeSyncDescriptionBuilder
.GetDescriptionForTable(tableName, myConnection);
scopeDescription.Tables.Add(tableDecsription);
}
SqlCeSyncScopeProvisioning scopeProvisioning =
new SqlCeSyncScopeProvisioning(scopeDescription);
scopeProvisioning.SetCreateTableDefault(DbSyncCreationOption.Create);
scopeProvisioning.Apply(myConnection);
}
请告诉我这是否可行或者我是否做错了什么。谢谢你, 亚历克斯
Is it possible to apply a DbSyncScopeDescription to an existing SqlCeDatabase?
I'm trying to provision an existing database using a DbSyncScopeDescription built from this database.
This is the code i'm using to test this out. This should give you an idea of what I'm trying to do.
I get a SqlCeException on the last line with the message:
"The specified index does not exist. [ sysChangeTxBsn_idx ]".
private void Test()
{
DbSyncScopeDescription scopeDescription =
new DbSyncScopeDescription("MyScope");
foreach (string tableName in TableNames)
{
DbSyncTableDescription tableDecsription = SqlCeSyncDescriptionBuilder
.GetDescriptionForTable(tableName, myConnection);
scopeDescription.Tables.Add(tableDecsription);
}
SqlCeSyncScopeProvisioning scopeProvisioning =
new SqlCeSyncScopeProvisioning(scopeDescription);
scopeProvisioning.SetCreateTableDefault(DbSyncCreationOption.Create);
scopeProvisioning.Apply(myConnection);
}
Please let me know if this is possible or if I'm doing something wrong. Thank you,
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我要尝试的一件事是使用 在调用 SetCreateTableDefault 时跳过枚举值。
这些表已存在于数据库中,您无需创建它们。
另外,如果已启用更改跟踪,我过去在配置 SQL Server Compact Edition 数据库时会遇到问题。
干杯,
斯科特
One thing that I would try is to use the Skip enumeration value in the call to SetCreateTableDefault.
The tables are already present in the database and you do not need to create them.
Also, I have had problems provisioning SQL Server Compact Edition databases in the past if change tracking has already been enabled.
Cheers,
Scott