Hunar
Hunar

Reputation: 399

Synchronize two SQL Server database using Dotmim sync framework

I have a WinForms database driven application that I want to make it work in online/offline mode using Dotmim sync framework that I find an article by their author here.

The documentation for the library is here

this is my code to sync the two SQL Server databases one is localdb and the other one is now on the SQL Server Management Studio for the testing purpose:

            string connect = @"Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=bright_square_db;Integrated Security=SSPI;AttachDBFilename=D:\Folder\project_file\bright_square_db.mdf";

            string constring = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;

            SqlSyncProvider serverProvider = new SqlSyncProvider(constring);
            SqlSyncProvider clientProvider = new SqlSyncProvider(connect);

            SyncAgent agent = new SyncAgent(clientProvider, serverProvider, new string[] { "I have listed all the tables here" });

            var progress = new SynchronousProgress<ProgressArgs>(s => MessageBox.Show($"{s.Context.SyncStage}:\t{s.Message}"));
            var syncContext = await agent.SynchronizeAsync(progress);

            MessageBox.Show(syncContext.ToString());

But, when I try to run the code. I am getting this errorenter image description here

The columns that indicated in the error are for a table that created by the sync process named "scope_info" inside the SQL Server database.

Upvotes: 0

Views: 1067

Answers (1)

Hunar
Hunar

Reputation: 399

I have solved the problem by swapping the client and server connection string link in the third and fourth line of the above code. I don't know what exactly cause the problem, but lastly this changed makes the code work for me.

Upvotes: 1

Related Questions