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
);
Sync tables with char type primary key
Re: Sync tables with char type primary key
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:
2. Run this code to provision both databases:
3. Add a record in any Products table (in test2 or in test3).
4. Synchronize databases:
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.
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
);
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();
}
}
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();
}
}
For more information, refer to https://www.devart.com/dotconnect/mysql ... ework.html.