views:

238

answers:

1

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

A: 

Hi Alex,

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

Scott Munro
Thanks for taking the time to respond. I ended up resturcturing things so that I can apply scope to my SqlCe database when it is created.
Alex