locked
Sync Postgresql with sql 2012 LocalDB RRS feed

  • Question

  • Hi, 

    i am currently write a App in C# with a PostgreSql Database.

    So some Employees need to work local. So i decided to use a LocalDB. 

    I am using Devart dotConnect PostgreSql v7.3.201 which include a SyncFramework.

    So i can Sync two PostgreSql Databases and that works very fine.

    Now i want to sync the PostgreSql with the LocalDB. The Problem is that Provisioning throw an Exception the column int4 could not created. 

    Is there a Workaround to change the datatypes or is that not possible?

    Thomas Heinze 

    Thursday, November 13, 2014 5:57 PM

Answers

  • So i´ve got a Solution from Devart Forum.

    First i've to create the table an then i have to scope to the LocalDb.

    And then it works very simple.

    PgSqlConnection serverConnection = new PgSqlConnection();
    serverConnection.ConnectionString = "PostgreSQL connection string";
    
    SqlConnection clientConnection = new SqlConnection();
    clientConnection.ConnectionString = "SQL Server connection string";
    
    DbSyncScopeDescription scopeDescription = new DbSyncScopeDescription("ResultsScope");
    DbSyncTableDescription tableDescription = PgSqlSyncDescriptionBuilder.GetDescriptionForTable("RESULTS", serverConnection);
    
    scopeDescription.Tables.Add(tableDescription);
    PgSqlSyncScopeProvisioning serverProvision = new PgSqlSyncScopeProvisioning(serverConnection, scopeDescription);
    serverProvision.Apply();
    
    DbSyncScopeDescription scopeDescription2 = new DbSyncScopeDescription("ResultsScope2");
    DbSyncTableDescription tableDescription2 = SqlSyncDescriptionBuilder.GetDescriptionForTable("RESULTS", clientConnection);
    
    scopeDescription2.Tables.Add(tableDescription2);
    SqlSyncScopeProvisioning clientProvision = new SqlSyncScopeProvisioning(clientConnection, scopeDescription2);
    clientProvision.Apply();
    
    SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
    syncOrchestrator.RemoteProvider = new PgSqlSyncProvider("ResultsScope", serverConnection, null, null);
    syncOrchestrator.LocalProvider = new SqlSyncProvider("ResultsScope2", clientConnection, null, null);
    syncOrchestrator.Synchronize();
    
    PgSqlSyncScopeDeprovisioning deprovision = new PgSqlSyncScopeDeprovisioning(serverConnection);
    deprovision.DeprovisionScope("ResultsScope");
    
    SqlSyncScopeDeprovisioning deprovision2 = new SqlSyncScopeDeprovisioning(clientConnection);
    deprovision2.DeprovisionScope("ResultsScope2");

    • Marked as answer by JuneT Tuesday, November 18, 2014 2:13 AM
    Friday, November 14, 2014 3:57 PM