Synchronize Databases with Only Five Lines of Code

Jeremy Likness ⚡️ - Sep 4 '20 - - Dev Community

DotMim.sync is a framework for synchronizing relational databases. It is a .NET Standard 2.0 library, which means it will run on multiple platforms including Windows, Linux, iOS and Android (via Xamarin) and more. It is production-ready and has been evolving for nearly a decade. The following code sample shows how easy it is to get started. This will automatically sync a client, including creating the tables and populating the data if the database doesn't already exist.

// Sql Server provider, the "server" or "hub".
SqlSyncProvider serverProvider = new SqlSyncProvider(
    @"Data Source=.;Initial Catalog=AdventureWorks;" +
    "Integrated Security=true;");

// Sqlite Client provider acting as the "client"
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);

do
{
    var result = await agent.SynchronizeAsync();
    Console.WriteLine(result);

} while (Console.ReadKey().Key != ConsoleKey.Escape);

In this episode of the EF Core Community Standup, the team talks with creator Sébastien Pertus who shares the project's history and demos several scenarios that illustrate how fast and easy the framework is to use.

You can find the links that were discussed in the show at:

https://www.theurlist.com/efcore-standup-2020-09-02.

Have feedback for the EF Core team? File an issue or join one of our many online discussions.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .