none
Error in provisioning databases RRS feed

  • Question

  • I am using sync framework SDK to sync tables accross databases. the tables to be synced are read from an XML file.

    Teh admin can add/remove tables in the XML files, so I must provision the tables which have been added. I have written the following code to provision the new tables

     

          string localFQDN = configHelper.GetLocalServerFQDN();
          List<string> databaseList = configHelper.GetDatabaseList();
          Dictionary<string, string> conStrMap = new Dictionary<string, string>();
          foreach(string dbName in databaseList) {
            conStrMap.Add(dbName, "Data Source=" + localFQDN + ";Initial Catalog=" + dbName + ";Integrated Security=True;");
          }
    
          foreach (string dbName in databaseList) {
            SqlConnection serverCon = new SqlConnection(conStrMap[dbName]);
            serverCon.Open();
            string schema = configHelper.GetDatabaseSchema(dbName);
            DbSyncScopeDescription scopeDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope(dbName + "Scope", null, schema, serverCon);
            if (scopeDesc == null) {
              scopeDesc = new DbSyncScopeDescription(dbName + "Scope");
            }
            List<string> tableList = configHelper.GetTables(dbName);
            
            foreach (string table in tableList) {
              DbSyncTableDescription tableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable(table, serverCon);
              if (scopeDesc.Tables.Contains(tableDesc) == false) scopeDesc.Tables.Add(tableDesc);
            }
    
            SqlSyncScopeProvisioning serverProvision = new SqlSyncScopeProvisioning(serverCon, scopeDesc);
            serverProvision.ObjectSchema = configHelper.GetDatabaseSchema(dbName);
            serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip);
            // start the provisioning process
            serverProvision.Apply();
            serverCon.Close();
          }
    

    Could not create a scope with name 'TestDB2Scope' as a scope with that name already exists.
       at Microsoft.Synchronization.Data.SqlServer.SqlSyncScopeProvisioning.ApplyScope(SqlConnection connection)
       at Microsoft.Synchronization.Data.SqlServer.SqlSyncScopeProvisioning.ApplyInternal(SqlConnection connection)
       at Microsoft.Synchronization.Data.SqlServer.SqlSyncScopeProvisioning.Apply()
       at SyncFrameworkTest.DataSynchronizer.ProvisionDatabases() in C:\myapps\SyncFramework\SyncFrameworkTest\DataSynchroni
    zer.cs:line 73
       at SyncFrameworkTest.Program.Main(String[] args) in C:\myapps\SyncFramework\SyncFrameworkTest\Program.cs:line 11

     

    I want to update the existing scope on the server .... how to do this?

     

    Edit:: I don't want to delete/deprovision the scope because there might be tables which are being synchronized... so just to add a new table, I don't want to disturb the tables which are already being synced.

    Friday, February 25, 2011 8:41 AM

Answers

  • Yes, you would quiesce the system, make your admin changes and re-setup. While not ideal and inconvenient, it is a limitation right now.

    The dates for the next version of SyncFx is not decided. As soon as we make a decision, we will publicize it.

    Each table in its own scope can work - but you have to remember that it can also become a management headache of many scopes - depending on how many tables you have and if there are relationships between the tables.


    This posting is provided AS IS with no warranties, and confers no rights
    Friday, February 25, 2011 10:03 PM

All replies

  • Unfortnately in SyncFx 2.1 you cannot add tables (or remove tables from) dynamically from an existing scope without deprovisioning. Really the supported way is to deprovision the existing scope, add more tables into your scope, then reprovision.

    The other thing you can do is create a new scope with the new tables and sync them.


    This posting is provided AS IS with no warranties, and confers no rights
    Friday, February 25, 2011 9:28 AM
  • > Really the supported way is to deprovision the existing scope, add more tables into your scope, then reprovision.

    But this will break the sync of existing tables right? because the moment I deprovision, all metadata tables will be deleted and therefore the sync will break for existing table. correct?

    So from an operations perspective I should run a complete sync so that all tables are the same. stop all changes. then create a new scope. start the changes, start the periodic job to sync.

    What is the ETA for the next version of Sync Framework? I did see a 4.0 CTP. Does the next version allow updatable Scopes?

    Also, do you think its a good idea to have a scope for each table? this way it will be easy for me to add/remove scopes if tables are added/removed from sync.

    Please do answer.

    Friday, February 25, 2011 9:48 AM
  • Yes, you would quiesce the system, make your admin changes and re-setup. While not ideal and inconvenient, it is a limitation right now.

    The dates for the next version of SyncFx is not decided. As soon as we make a decision, we will publicize it.

    Each table in its own scope can work - but you have to remember that it can also become a management headache of many scopes - depending on how many tables you have and if there are relationships between the tables.


    This posting is provided AS IS with no warranties, and confers no rights
    Friday, February 25, 2011 10:03 PM