Sync tables with char type primary key

Sync tables with char type primary key

Postby algirtas » Mon 13 Jun 2016 08:27

Hi,
I followed "Sync Framework Tutorial for MySQL" and tried to sync table witch has char type primary key (see example below), and it seams that framework doesn't see changes then trying to do sync. Am I able to do sync with such table?

CREATE table `Products`
(
`Id` CHAR(38) NOT NULL PRIMARY KEY,
`Name` VARCHAR(100),
`CategoryId` INT,
`IsAvailable` BOOL
);
algirtas
 
Posts: 1
Joined: Mon 13 Jun 2016 07:09

Re: Sync tables with char type primary key

Postby Shalex » Wed 22 Jun 2016 17:55

We cannot reproduce the issue in our environment. Please try the following walkthrough:

1. Create two test databases (e.g.: test2, test3) at your MySQL Server and populate both with the table:
Code: Select all
CREATE table `Products`
(
`Id` CHAR(38) NOT NULL PRIMARY KEY,
`Name` VARCHAR(100),
`CategoryId` INT,
`IsAvailable` BOOL
);

2. Run this code to provision both databases:
Code: Select all
    using (var serverConn = new MySqlConnection("server=db;port=3311;database=test2;uid=root;pwd=root;")) {
        var scopeDesc = new DbSyncScopeDescription("a");
        var tableDesc = MySqlSyncDescriptionBuilder.GetDescriptionForTable("products", serverConn);
        scopeDesc.Tables.Add(tableDesc);
        var serverProvision = new MySqlSyncScopeProvisioning(serverConn, scopeDesc);
        serverProvision.Apply();

        using (var clientConn = new MySqlConnection("server=db;port=3311;database=test3;uid=root;pwd=root;")) {
            var scopeDescription = MySqlSyncDescriptionBuilder.GetDescriptionForScope("a", serverConn);
            SyncScopeProvisioning productionProvisioning = new MySqlSyncScopeProvisioning(clientConn, scopeDescription);
            productionProvisioning.Apply();
        }
    }

3. Add a record in any Products table (in test2 or in test3).

4. Synchronize databases:
Code: Select all
    using (var serverConn = new MySqlConnection("server=db;port=3311;database=test2;uid=root;pwd=root;")) {

        using (var clientConn = new MySqlConnection("server=db;port=3311;database=test3;uid=root;pwd=root;")) {

            SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
            syncOrchestrator.RemoteProvider = new MySqlSyncProvider("a", serverConn, null, null);
            syncOrchestrator.LocalProvider = new MySqlSyncProvider("a", clientConn, null, null);
            syncOrchestrator.Synchronize();
        }
    }

Does this work? If not, please enable the dbMonitor tool and localize the SQL statement which fails to execute: https://www.devart.com/dotconnect/mysql/docs/?dbmonitor.html.

For more information, refer to https://www.devart.com/dotconnect/mysql/docs/?SyncFramework.html.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for MySQL