none
Cannot synchronize two provisioned identical copies of a database, due to DuplicateNameException

    Question

  • Hi,

    I'm trying to sync two SqlCe database with Sync Fx 2.1. I provisioned the source, then copied it (via Windows Explorer) to a target db.

    I tried to sync the two using the Sync Orchestrator, and got DuplicateNameException, with the following message: "A column named '__sysTrackingContext' already belongs to this DataTable."

    I can't for the life of me understand what the problem is.

    Can anybody help me understand?

    Thanks,

    Assaf.

    Tuesday, August 31, 2010 6:55 AM

Answers

  • afaik, Sync Fx v2.1 should automatically be updating the existing SDF to 3.5 SP2 when it connects to it.

    i just did exactly what you're trying to do and didnt get any error. The only notable difference is that my first SDF was previously created by Sync Fx v2.1 as well.

    as an extra step, before provisioning the first SDF, try disabling the tracking.  (am assuming you want to use the existing 3.5 SP1 rather than create a new one on SP2 because you already have data in this SDF)

    e.g.,

    //disable existing tracking

    SqlCeChangeTracking ceChangeTracking = SqlCeChangeTracking();
    ceChangeTracking.DisableTracking(tablename);

    //do provisioning here

    i dont have 3.5 SP1 to simulate so am not sure if it will work.

     

     

    Tuesday, August 31, 2010 8:58 AM

All replies

  • use SqlCeSyncStoreSnapshotInitialization.GenerateSnapshot to generate the second database. you can't just copy the SDF file as there are some metadata initialization done for each copy/replica participating in the sync.
    Tuesday, August 31, 2010 7:18 AM
  • Hi June,

    I tried generating a snapshot, rather than copying the provisioned SDF. I still get the same error.

    The flow I used was as such:

          using (SqlCeConnection remoteConnection = new SqlCeConnection(RemoteConnectionString),
            localConnection = new SqlCeConnection(LocalConnectionString))
          {
            if (!File.Exists(localConnection.Database))
            {
              var syncStoreSnapshot = new SqlCeSyncStoreSnapshotInitialization();
              syncStoreSnapshot.GenerateSnapshot(remoteConnection, localConnection.Database);
            }
          }
    
    
          using (SqlCeConnection localConnection = new SqlCeConnection(LocalConnectionString),
                      remoteConnection = new SqlCeConnection(RemoteConnectionString))
          {
            try
            {
              var syncOrchestrator = new CitSyncOrchestrator
                (
                new SqlCeSyncProvider(Scope.ToString(), localConnection),
                new SqlCeSyncProvider(Scope.ToString(), remoteConnection)
                );
              LastSyncResults = syncOrchestrator.Synchronize();
            }
            catch (DbSyncException ex)
            {
              // TODO : Handle Exception / log
              throw;
            }
          }
    
    

    When I get to the syncOrchestrator.Synchronize() method, it stops on the aforementioned exception.

    Could this perhaps be a SqlCe version error? I installed SqlCe 3.5 SP2, but as far as I know, the SDF file was generated in SP1.

     

    Thanks,

    Assaf.

    Tuesday, August 31, 2010 8:32 AM
  • afaik, Sync Fx v2.1 should automatically be updating the existing SDF to 3.5 SP2 when it connects to it.

    i just did exactly what you're trying to do and didnt get any error. The only notable difference is that my first SDF was previously created by Sync Fx v2.1 as well.

    as an extra step, before provisioning the first SDF, try disabling the tracking.  (am assuming you want to use the existing 3.5 SP1 rather than create a new one on SP2 because you already have data in this SDF)

    e.g.,

    //disable existing tracking

    SqlCeChangeTracking ceChangeTracking = SqlCeChangeTracking();
    ceChangeTracking.DisableTracking(tablename);

    //do provisioning here

    i dont have 3.5 SP1 to simulate so am not sure if it will work.

     

     

    Tuesday, August 31, 2010 8:58 AM