SqlSyncScopeProvisioning in CTP2 with SQL Server 2008 RRS feed

  • Question

  • Hi, I was trying to write a simple Sql-to-SqlCe sync sample, following the article from documentation.
    But every time I'm calling Apply() method on SqlSyncScopeProvisioning, it throws exception "Incorrect syntax near 'scope_update_peer_key'".
    SQL Server Profiler shows that it fails trying to execute the following command:

    CREATE TABLE [streets_tracking] ([update_scope_local_id] int NULL[scope_update_peer_key] int NULL[scope_update_peer_timestamp] bigint NULL[local_update_peer_key] int NOT NULL[local_update_peer_timestamp] timestamp NOT NULL[create_scope_local_id] int NULL[scope_create_peer_key] int NULL[scope_create_peer_timestamp] bigint NULL[local_create_peer_key] int NOT NULL[local_create_peer_timestamp] bigint NOT NULL[sync_row_is_tombstone] int NOT NULL[restore_timestamp] bigint NULL[last_change_datetime] datetime NULL)

    As you can see, there's no commas in table definition. It's strange, because it seems, that I'm the only one with this problem.

    The table itself is scripted as follows:

    	[REC_NUM] [int] NOT NULL,
    	[KOD_R] [nvarchar](2) NULL,
    	[TOWN] [nvarchar](100) NULL,
    	[PUNKT] [nvarchar](100) NULL,
    	[STREET] [nvarchar](110) NULL


    using (var sqlConnection = new SqlConnection(sqlConnectionString))
    using (var sqlCeConnection = new SqlCeConnection(sqlCeConnectionString))
    	var dbSyncScopeDescription = new DbSyncScopeDescription(scopeName);
    	foreach (var table in tables)
    		dbSyncScopeDescription.Tables.Add(SqlSyncDescriptionBuilder.GetDescriptionForTable(table, sqlConnection));
    	var serverConfig = new SqlSyncScopeProvisioning(dbSyncScopeDescription);
    	serverConfig.Apply(sqlConnection); //<-- Exception
    	//rest of the code

    I'm using Sync Framework 2.0 CTP2, SQL Server 2008 SP1 (Developer Edition) running on Windows 7 RC x64.
    • Edited by 13xforever Friday, August 21, 2009 11:46 AM argh, this code block is a mess
    • Moved by Max Wang_1983 Thursday, April 21, 2011 11:56 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, August 21, 2009 11:40 AM


  • The issue is that the table Streets doesn't have a Primary Key defined and synchronization requires that your tables have a primary key defined.

    This will be properly detected in RTM and throw a more friendly/informative exception.

    • Proposed as answer by Phil Piwonka Friday, August 21, 2009 6:47 PM
    • Marked as answer by 13xforever Sunday, August 23, 2009 5:57 AM
    Friday, August 21, 2009 6:47 PM