none
Migration of SqlServerCe DB from microsoft sync framework 1.0 to microsoft sync framework 2.0 RRS feed

  • Question

  • Hi,
    I am trying to migrate my application from sync frame 1.0 tp sync framework 2.0.
    Since its the compulsion that I can't replace my older *.sdf files(created by MSF 1.0), that are acting as my Source Data Base file while synchronization,
    Now keeping the older *.sdf files for synchronization I am getting SqlCeException from SqlCeSyncScopeProvisioning class while provisioning the .sdf file , And the exception is:-

    The specified index does not exist. [ sysChangeTxBsn_idx ]

    Could anyone of please help me to overcome this exception and make my older *.sdf files compatible against the MSF 2.0 environment and functionality?

    Thanks!
    Babit Singh
    Monday, February 15, 2010 9:47 AM

Answers

  • can you post the stack trace? 

    i guess you've dabbled enough on getting it to work within SyncFx. If you're out of time and had enough trying to get it done using SyncFx, copying the contents of the old DB to a newly provisioned DB will probably be faster option :)
    • Marked as answer by Babit Singh Wednesday, March 10, 2010 4:17 AM
    Wednesday, February 17, 2010 4:55 AM
    Moderator
  • Indeed, I would second JuneT here. this is not a supported scenario (to "update" V1 client to V2 client with the new provisioning logic, tracking metadata etc). even if the data is fairly big, re-create the sync with newer bits would be a less complicated way to achieve this.

    thanks
    yunwen


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, February 17, 2010 8:29 AM
    Moderator

All replies

  • hi Babit,

    just trying to clarify what your requirements and the error your encountering:

    1. You want to migrate you SyncFx v1  to SyncFx 2.0
    2. You want to migrate your existing SyncFx v1 SDFs to SyncFx 2.0 compatible SDF.
    3. To do the migration, you set up a new sync using your old v1 SDF as the source and provisioning a new v2 SDF based on the old v1 SDF

    Is that right? can you post some code for clarity?

    Cheers,

    JuneT
    Monday, February 15, 2010 11:08 AM
    Moderator
  • Another solution is to upload all the client side changes and re-create the client db using the MSF V2 SQL CE providers.

    Thanks.
    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, February 15, 2010 10:13 PM
    Answerer
  • Thanks JuneT and L Zhou for thereply ..
    JuneT-
    Right, all your points and understanding is upto the requirement that I actually want.
    I will be showing you the actuall error and respective code:-
      SqlCeConnection connection = new SqlCeConnection(connectionString);
    
                //Provider Initialization with specified SqlCe Db connection
                SqlCeSyncProvider provider = new SqlCeSyncProvider();
                provider.MemoryDataCacheSize = 5120;
                provider.ScopeName = scopeName;
                provider.BatchingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                provider.SyncProgress += new EventHandler<DbSyncProgressEventArgs>(provider_SyncProgress);
                provider.BatchSpooled += new EventHandler<DbBatchSpooledEventArgs>(provider_BatchSpooled);
                provider.CleanupBatchingDirectory = false;
                provider.Connection = connection;
    
                //Check the SDF file to be synchronized exists in the folder.
                if (!File.Exists(connection.Database))
                {
                    SqlCeEngine engine = new SqlCeEngine(connectionString);
                    engine.CreateDatabase();
                    engine.Dispose();
                }
                else
                {
    
                }
    
                //class to be used to provision the scope defined above 
                SqlCeSyncScopeProvisioning serverConfig = new SqlCeSyncScopeProvisioning();
    
                serverConfig.SetCreateTableDefault(DbSyncCreationOption.Create);
                serverConfig.PopulateFromScopeDescription(scopeDesc);
                serverConfig.Apply(connection);
    
                return provider;
            }
    at the line  " serverConfig.Apply(connection);" , i am getting the error.


    L Zhou-
    I can't upload the older db via wcf channel since its of arround 700MB size.

    Can we create the same index in older db manually using SqlServerManagement Studio , will that work in that condition?
    Or its should be created by MSF 2.0 in the SDF file?
    Tuesday, February 16, 2010 7:21 AM
  • can you post the code where you actually define/derive the scopedesc?
    Tuesday, February 16, 2010 8:32 AM
    Moderator
  • Ya sure JuneT, actually i have wcf service service, that get me the scope description from Server DB (n-tier syncing).
    So from proxy I am retrievig the ScopeDescrioption of particular Scope with the tables its consisting of.

    WCF Service's GetScopeDescription() method is given below:-
       public DbSyncScopeDescription GetScopeDescription()
            {
                DbSyncScopeDescription scopeDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope
                                                   (
                                                    scopeName,
                                                    sqlDbConnection
                                                   );
                return scopeDesc;
            }
     
    But JuneT, if i don't use the older DB(*.sdf), it creats a new DB(*.sdf) and that works fine for me.
    Its only this index error that is creating conflict in older and newer client DB(.sdf) 
    Tuesday, February 16, 2010 8:53 AM
  • looking inside the SyncFx call to the Apply method, it's actually trying to drop the index when you use the DbSyncCreationOption.Create option and when your DB already has the tables in the scope.

    Have you tried using DbSyncCreationOption.Skip for your old DB?

    Tuesday, February 16, 2010 9:59 AM
    Moderator
  • You mean to say DbSyncCreationOption.Skip? or DbSyncCreationOption.Create[Last Line]
    Tuesday, February 16, 2010 10:01 AM
  • Skip. i edited it.

    Tuesday, February 16, 2010 10:03 AM
    Moderator
  • Ya , same also I have tried for that. But in case if i create new DB though SqlCeEngine its works fine

     SqlCeEngine engine = new SqlCeEngine(connectionString);
                    engine.CreateDatabase();
                    engine.Dispose();


    but if I use the older DB with same code it throws the above exception.
    Tuesday, February 16, 2010 10:07 AM
  • it works with a new blank db since it exits the part that drops the index when the tables are not found in the new DB. However, if you use DbSyncCreationOption.Create on an existing DB, it checks if the tables exists and if they do, it does some cleanup which eventually leads to the call to drop the index.
    Tuesday, February 16, 2010 10:14 AM
    Moderator
  • i think if you copy the index definition from the new DB you created, it might just work.

    Tuesday, February 16, 2010 10:20 AM
    Moderator
  • But JuneT, I opened my old DB sdf file in SqlServer Management Studio there this index is not present ,

    where as incase of new Db its visible.
    Tuesday, February 16, 2010 10:23 AM
  • exactly, so just script out the index from the new DB and run it on the old DB.

    Tuesday, February 16, 2010 10:26 AM
    Moderator
  • In DbSyncCreationOption.Skip with the old db it throws the same exception, no effect.
    Tuesday, February 16, 2010 10:28 AM
  • to copy the index definition, I should use Linq to Sql or using Sql Query Editor in SqlManagement Studio.
    Tuesday, February 16, 2010 10:31 AM
  • hi Babit,

    can you interchange these lines?

     serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
     serverConfig.PopulateFromScopeDescription(scopeDesc);

    to:

    serverConfig.PopulateFromScopeDescription(scopeDesc);
    serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);


    the call to SetCreateTableDefault loops thru the tables collection, but the problem with doing this is that the tables collection is only populated in the call to PopulateFromScopeDescription
               
    Tuesday, February 16, 2010 10:55 AM
    Moderator
  • JuneT I did that also but now I am getting a different error.

    "Invalid Parameter" while using the older DB.

    Wednesday, February 17, 2010 4:44 AM
  • can you post the stack trace? 

    i guess you've dabbled enough on getting it to work within SyncFx. If you're out of time and had enough trying to get it done using SyncFx, copying the contents of the old DB to a newly provisioned DB will probably be faster option :)
    • Marked as answer by Babit Singh Wednesday, March 10, 2010 4:17 AM
    Wednesday, February 17, 2010 4:55 AM
    Moderator
  • Indeed, I would second JuneT here. this is not a supported scenario (to "update" V1 client to V2 client with the new provisioning logic, tracking metadata etc). even if the data is fairly big, re-create the sync with newer bits would be a less complicated way to achieve this.

    thanks
    yunwen


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, February 17, 2010 8:29 AM
    Moderator
  • Thanks JuneT and Yunwen. Sorry for late reply, you  are right JuneT , copying the data to the newer DB is the only option to get rid of the situtation. I am doing the same. Thanks for your support.

    Wednesday, March 10, 2010 4:17 AM