How to synchronize incremental data changes between server and client (bi-direction) using Sync Framework 2.1? RRS feed

  • Question

  • Hello,

    I want to synchronize only those data changes that are happened after last sync between client and server. I require this for below two things

    1. Because every time I do sync using Sync Fx 2.1, I observe some bulk of rows getting synchronized. I observe this in SyncOperationStatistics.DownloadChangesTotal and SyncOperationStatistics.UploadChangesTotal properties which remains constant always. Also noticed that though, there is no change in data in both local and server DB, sync still happens with same amount of change.
    2. Secondly, I have used UploadAndDownload as sync direction. So, entire data is uploaded from client to server and again all data are downloaded from server to client. This is apparently increasing the sync time.

    What I want is just to exchange incremental data changes. How to achieve this using Sync Fx 2.1?

    Any help is really appreciated.



    • Edited by snabhi Tuesday, December 10, 2019 12:47 PM
    Tuesday, December 10, 2019 12:43 PM

All replies

  • Look at `Dotmim.Sync` framework here : https://github.com/Mimetis/Dotmim.Sync

    This framework allows you to create a full synchronization between two databases (`Sql`, `Sqlite`, `MySql`) with a little bit of code.

    // Sql Server provider, the master.
    SqlSyncProvider serverProvider = new SqlSyncProvider(
        @"Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=true;");
    // Sqlite Client provider for a Sql Server <=> Sqlite sync
    SqliteSyncProvider clientProvider = new SqliteSyncProvider("advworks.db");
    // Tables involved in the sync process:
    var tables = new string[] {"ProductCategory",
        "ProductDescription", "ProductModel",
        "Product", "ProductModelProductDescription",
        "Address", "Customer", "CustomerAddress",
        "SalesOrderHeader", "SalesOrderDetail" };
    // sync agent
    SyncAgent agent = new SyncAgent(clientProvider, serverProvider, tables);
        var s = await agent.SynchronizeAsync();
        Console.WriteLine($"Total Changes downloaded : {s.TotalChangesDownloaded}");
    } while (Console.ReadKey().Key != ConsoleKey.Escape);

    The version `v0.4` is still in pre-release, but it comes with some new cool features like change tracking for SQL Server.

    You should check if you are searching an alternative to Sync Framework

    Sébastien Pertus. Microsoft France. Technical Evangelist

    Friday, January 31, 2020 1:54 PM
  • Before you could use the code given by Sebastein Pertus you need to follow these steps:

    • Create a .Net Core 2.0 or .Net Fx 4.6 console application.
    • Add the nugets packages DotMim.Sync.SqlServer and DotMim.Sync.Sqlite

    I hope this information helps!

    Friday, January 31, 2020 2:14 PM