Bluephlame
Bluephlame

Reputation: 3969

One-Way sync of data without changing schema of source database

I Have a database that we want to partially sync data out of into another database (on Azure).

I have been looking at Sync Framework 2.1 and believe it can solve the problem, however i cannot figure it out from the online documentation.

We have the restraint that we cannot change the schema of the database however we are on SQL 2008 R2 which means that we can use track changes.

I am looking for some advise on how this might be achieved.

currently i have a SyncOrchestrator

        var orch = new SyncOrchestrator
        {
            LocalProvider = new SampleServerSyncProvider(),
            RemoteProvider = new SampleClientSymcProvider(),
            Direction = SyncDirectionOrder.Upload
        };

and then a sync provider

public class SampleServerSyncProvider : DbServerSyncProvider
{
    private String SQLLocalConnection = "valid connection string";
    public SampleServerSyncProvider()
    {            
        SqlConnection serverConn = new SqlConnection(SQLLocalConnection);
        Connection = serverConn;
        Connection.Open();
        var cmTableSyncAdapter = new SqlSyncAdapterBuilder
        {
            Connection = serverConn,
            ChangeTrackingType = ChangeTrackingType.SqlServerChangeTracking,
            SyncDirection = SyncDirection.Bidirectional,
            TableName = "my table"
        };                
        SyncAdapters.Add(cmTableSyncAdapter.ToSyncAdapter());
    }
}

Currently i am getting an error that talks about initializing the connection. But I cannot find an initialize method on any of the objects

System.InvalidOperationException : Cannot create a SyncAdapter for table 'My table' by using SqlSyncAdapterBuilder because the connection to the server has not yet been initialized. Initialize the Connection property of the SqlSyncAdapterBuilder before you call any of the SqlSyncAdapterBuilder methods

Upvotes: 0

Views: 338

Answers (1)

JuneT
JuneT

Reputation: 7860

SQL Change Tracking is only supported on the older offline providers (SqlClientSyncProvider/DbServerSyncProvider/SyncAgent). The newer providers you're trying to use (SqlSyncProvider/SyncOrchestrator) requires a custom change tracking. You cannot mix and match the database sync providers.

have you looked at using SSIS instead?

Upvotes: 1

Related Questions