I’m attempting to synchronize a SQLite database with a PostgreSQL database using Dotmim.Sync. Here are the details of my setup:
Database Providers:
Client (SQLite): new SqliteSyncProvider(@"Data Source=C:Desktoptest.db")
Server (PostgreSQL): new NpgsqlSyncProvider(serverConnectionString)
Table Structures:
SQLite table (client):
CREATE TABLE "trackplot_cog" (
"gid" INTEGER PRIMARY KEY AUTOINCREMENT,
"id" INTEGER,
"timestamp" TEXT,
"name" TEXT,
"lat" REAL,
"long" REAL
);
PostgreSQL table (server):
CREATE TABLE dataengine.trackplot_cog (
gid serial primary key,
id integer,
"timestamp" timestamp,
name character varying(255),
lat numeric (38,8),
long numeric (38,8)
);
Synchronization Method:
I’m initiating the sync process using the following code:
var syncAgent = new SyncAgent(clientProvider, serverProvider);
var setup = new SyncSetup("dataengine.trackplot_cog");
var result = await syncAgent.SynchronizeAsync(setup);
Error:
When I run the synchronization, I receive the following error:
CopySynchronization error:
[InternalEnsureScopelnfoAsync].Overwrite:False .. [InternalGetSchemaAsync] ..
[InternalGetTableSchemaAsync].Table:dataengine.trackplot_cog ..
[SetPrimaryKeysAsync].Table:dataengine.trackplot_cog ..
Table trackplot_cog does not have any primary key.
Stack Trace: at Dotmim.Sync.SyncAgent.SynchronizeAsync(String scopeName,
SyncSetup setup, SyncType syncType, SyncParameters parameters,
CancellationToken cancellationToken, IProgress`1 progress)
at SyncService.cs:line 76
Dotmim.Sync is unable to detect the primary key in the dataengine.trackplot_cog table, despite both tables having a primary key defined on the gid column.
Why is Dotmim.Sync failing to recognize the primary key in my PostgreSQL table?
Are there any additional configuration steps I need to take to ensure proper primary key detection?
Could there be any issues with schema detection or naming conventions that I’m overlooking?