Skip to content
A database schema diff and sync library for any IDbConnection. Powers my SQL Model Merge app
C#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ConsoleApp
SchemaSync.Library
SchemaSync.MySql
SchemaSync.Postulate
SchemaSync.SqlServer
Tests.MySql
Tests
.gitattributes
.gitignore
LICENSE
README.md
SchemaSync.sln

README.md

SchemaSync

Nuget package: SchemaSync.Library

Background

For a long time I've wanted my own database schema diff/merge app. There are several such tools from ApexSQL, Red Gate, AquaFold, SQL Accessories, and I'm sure others. I've made a couple stabs at this that were part of my Postulate ORM project, which I'm no longer updating. (Note, "Postulate.Orm" was an old iteration. The latest that I am updating is Postulate.) My "model merge" feature was for supporting code-first ORM by merging C# model classes to SQL Server objects. I'm into this because I don't like Entity Framework and its migration feature. However, my old approach had several limitations:

  • It works only C#-to-database. There's no database-to-database merging.
  • It's coupled to Postulate ORM model classes.
  • It works only for SQL Server.
  • It handles only table-related changes (tables, columns, foreign keys), not stored procedures, views nor other objects.

This library is addressing these limitations to varying degrees. The main goals are:

  • Do C#-to-database and data-to-database merges equally well
  • Work with any source ORM or database platform through a Provider pattern

Tools

This library is used by a couple tools of mine in development:

  • a free command-line tool here for merging from C# classes to SQL Server.
  • a commercial GUI tool available SQL Model Merge for merging code-to-database as well as database-to-database.

Architecture

SchemaSync has a model layer that virtualizes database metadata -- whether it comes from a physical database or .NET assembly of model classes. The Database object is the root object from which child objects (Tables, ForeignKeys, Views, Procedures) are collected under.

To support a particular ORM model class assembly or database backend, there's an interface to implement: IDbAssemblyProvider or IDbConnectionProvider.

As I said above, SchemaSync has no particular ORM dependency, but I do want it to work with Postulate Lite. So, a Postulate Provider is part of the solution. Likewise, there's a SQL Server Provider as well as MySQL Provider.

To create a new SchemaSync Provider, add the Nuget project SchemaSync.Library to your solution and implement either IDbAssemblyProvider or IDbConnectionProvider depending on the type of provider you want to create.

To see how this library is used, please have a look at my app SQL Model Merge.

You can’t perform that action at this time.