Sync tables with char type primary key

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
algirtas
Posts: 1
Joined: Mon 13 Jun 2016 07:09

Sync tables with char type primary key

Post by 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
);

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Sync tables with char type primary key

Post by 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 ... nitor.html.

For more information, refer to https://www.devart.com/dotconnect/mysql ... ework.html.

Post Reply