Nuget package: SchemaSync.Library
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
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.
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.
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
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.