.NET Client Library

A .NET Client library for MySQLSync can be obtained via NuGet:

Install-Package MySQLSyncClient.NET -Version 1.0.0

After we have referenced the client side library in our project, we can synchronize the remote MySQL database with a local SQLite db, using the following code blocks:

        string localDB = "c:\\temp\\testdbase_net.db";
        string dbPart = "demo";
        string syncServer = "http://localhost:8877";
        MySQLSyncClient.DBPart part = new MySQLSyncClient.DBPart(localDB, dbPart, syncServer);
        part.Sync();

The initial synchronization the local SQLite database file will be filled with the remote DBPart structure and data.

Subsequent invocations of the Sync() method will result in uploading the local changes to the remote MySQL server and obtaining the remote changes locally.

Authentication

If Authentication is enabled on the MySQLSync server, we have to call SetAuth(user, pass) before invoking the Sync method, like

MySQLSyncClient.DBPart part = new MySQLSyncClient.DBPart(localDB, dbPart, syncServer);
part.SetAuth(txtUsername.Text, txtPassword.Text);
part.Sync();

Custom Authentication

If we want to use a custom Authentication source, we have to use the overloaded SetAuth(user, pass, schema) method instead. For example to use the sample SimpleDummyAuthenticator we are going to update the above code like:

MySQLSyncClient.DBPart part = new MySQLSyncClient.DBPart(localDB, dbPart, syncServer);
string schema = "simple";
part.SetAuth(txtUsername.Text, txtPassword.Text, schema); 
part.Sync();

The third parameter schema will have the same value as the one returned by the getSchema() method of the custom Authentication source.

Scroll to Top