微软同步框架。应用“范围”到现有的 SqlCe 数据库

发布于 2024-08-15 10:57:46 字数 897 浏览 1 评论 0原文

是否可以将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹊巢 2024-08-22 10:57:46

我要尝试的一件事是使用 在调用 SetCreateTableDefault 时跳过枚举值。

scopeProvisioning.SetCreateTableDefault(DbSyncCreationOption.Skip);

这些表已存在于数据库中,您无需创建它们。

另外,如果已启用更改跟踪,我过去在配置 SQL Server Compact Edition 数据库时会遇到问题。

干杯,

斯科特

One thing that I would try is to use the Skip enumeration value in the call to SetCreateTableDefault.

scopeProvisioning.SetCreateTableDefault(DbSyncCreationOption.Skip);

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文