1. Gideon Sireling
  2. hybrid


hybrid / Readme.md

Installation and Build Dependencies

Configuration Files

Remember that settings from dependent projects' .config may need to be manually merged into the main application's .config.

Database Server

  1. Install SQL Server.
  2. Build the Server project, then deploy the SQLCMD script from its output folder. Alternatively, double-click Server.publish.xml do build and publish.

When deploying synchronisation capabilities to an existing database, the following two adjustments must be made to each table:

  1. Add a timestamp column.
  2. Add a trigger that will update the timestamp when a row changes.

Web Server

  1. Install the Services project as an IIS application.
  2. Enable net.tcp transport.
  3. Edit the .config file to ensure that the connection strings and WCF configuration are correct.


  1. Install SQL Server Express on the client.
  2. Create an empty database called Client.
  3. Install the client application.
  4. Edit the client's .config to ensure that the connection strings and WCF configuration are correct.
  5. The Tables setting is a CSV list of which tables to synchronise.

ApexSQL Diff API

ApexSQL's licensing requires certain files to be available to the application at runtime. These are copied to the output directory by post-build events in the Services and Client applications. Beware that the WCF services will pop up a modal dialog upon the first schema synchronisation during the trial period, so someone has to be watching out for this.


The ApexSQL assemblies are x86. WcfSvcHost runs as x64. If you're running the solution from the IDE on an x64 machine, open a Visual Studio Command Prompt with administrator privileges at C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE. Then run:

copy WcfSvcHost.exe WcfSvcHost.exe.bak
corflags /32BIT+ WcfSvcHost.exe /Force
sn -Vr WcfSvcHost.exe

Synchronisation Conflicts

In the event of a conflict, the server always wins. This can probably be changed to client always wins, but the API does not allow for anything else.

Deleted rows are not synchronised.


The client and server are both configured to write WCF trace logs. The client also writes a plain-text error log. Inspect these to determine why it isn't working.

Common problems:

  1. WAS must be running on the web server, and .NET 4 correctly registered with IIS.
  2. The Services application requires write permissions for the location of its configuration log.
  3. Requests from the client must make their way to the database server with a valid database logon that has the necessary permissions.

The IdRanges Table

When a client connects to the server for the first time, it requests an ID range. These are tracked in the IdRanges table, and are negative. The server uses positive IDs. The IdRange setting in the Service's .config defines how many IDs to allocate to each client. The same range is used across all tables.

Solution Dependencies

Schema Synchronisation

The service and client have a SchemaVersion setting. Before the client synchronises, it checks the server's schema version. If this is greater than the client's schema, it will download a snapshot of the server's schema, and synchronise its local database. The ApexSqlTables setting in SyncClient is a comma-delimited list of regular expressions indicating which tables to synchronise. Ensure that none of the expressions match tracking tables.