locked
[V2 CTP2] Columns Default Value not synchronized RRS feed

  • Question

  • Hello,

    I am trying to use MSF V2 CTP2 to synchronize a table between 2 instances SQL Server 2008 Express.
    I use a collaborative architecture with two SqlSyncProvider, one for the local and one the remote peer.
    My starting situation is the following:
    - remote database created, contains a Customer table with a uniqueidentifier primary key which default value is set to '(newid())'
    - local database created, contains no table

    First of all, I create a DbSyncScopeDescription in order to provision the server and already there I get null default value for my primary key like shown in the code bellow :

    DbSyncScopeDescription scopeDesc = new
     DbSyncScopeDescription("filtered_customer"
    );
    DbSyncTableDescription table = SqlSyncDescriptionBuilder.GetDescriptionForTable("Customer"
    , serverConn);
    //table.Columns[0].DefaultValue is null !!!
    
    scopeDesc.Tables.Add(table);
    
    

    Nevermind at this step it does not bother me...
    Then I Apply that to the server like that :

    SqlSyncScopeProvisioning serverConfig = new
     SqlSyncScopeProvisioning(scopeDesc);
    serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
    
    serverConfig["Customer"
    ].AddFilterColumn("CustomerType"
    );
    serverConfig["Customer"
    ].FilterClause = "[side].[CustomerType] = 'Retail'"
    ;
    
    if
     (!serverConfig.ScopeExists("filtered_customer"
    , serverConn))
    	serverConfig.Apply(serverConn);
    

    Remember then that my local database does not contain any table...
    I will now apply this scope to my local database :

    DbSyncScopeDescription clientSqlDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope("filtered_customer"
    , serverConn);
    //clientSqlDesc.Tables[0].Columns[0].DefaultValue = "(newid())";
    
    SqlSyncScopeProvisioning clientSqlConfig = new
     SqlSyncScopeProvisioning(clientSqlDesc);
    if
     (!clientSqlConfig.ScopeExists("filtered_customer"
    , clientSqlConn))
    	clientSqlConfig.Apply(clientSqlConn);
    

    I am syncing my remote schema into my local one, but there everything is going fine except that the primary key is stuck to null, as in DbSyncScopeDescription structure that in SQL Server database.
    I can force its value with the commented line but I must be aware of server database schema at this point...

    So it smells like a bug, isn't it ?
    Or I must be missing something around ...

    Thanks in advance !
    Guim7
    Thursday, August 20, 2009 3:16 PM

Answers

  • The description will not pull the default value out of the database, so you will have to manually specify it.  We know about this inconvenience but for now you'll have to manually specify it.

    Thanks-
    Phil

    Friday, August 21, 2009 6:29 PM