locked
Sync Framework-2.0 SqlSyncProvider RRS feed

  • Question

  • Hi,

    In first run of my synchronization activity, I need metadata tables be created on teh server and client. For subsequent runs, i expect the tables to be created on client only if it is the first run from that client.

    How can I change the Creation.Create to Creation.Skip. ? I need to use Creation.Create again if some database is recreated. How can I achieve  this in easy way?

    Also, for concurrent users, doing synchronization job in parallel for the first time, won't there be any issues on Server as both the user would try to create the same metadata table?

    Thanks and Refgards,
    Swanand 
    Thursday, January 14, 2010 1:26 PM

Answers

  • Hi Swanand,

    The idea with the Collaboration Providers is that you provision your database the moment that you create it. So that you only need to do this once for every 'peer'.

    If you are using a hub-and-spoke model (1 Server and many Clients) then you would make sure the provisioning is done when the database is created (or when the application is moved to production).

    If however you want to find out programmatically if the client database is provisioned use code similar to this:
            private void EnsureScopeDescription(string scopeName, SqlConnection clientConnection, SqlConnection serverConnection)
            {
                //create a new scope description and add the appropriate tables to this scope
                DbSyncScopeDescription scopeDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope(scopeName, serverConnection);
    //class to be used to provision the scope defined above SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning(); //determine if this scope already exists on the client and if not go ahead and provision if (!serverConfig.ScopeExists(scopeName, clientConnection)) { //note that it is important to call this after the tables have been added to the scope serverConfig.PopulateFromScopeDescription(scopeDesc); serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip); //provision the server serverConfig.Apply(clientConnection); } }
    Thursday, January 14, 2010 2:28 PM