SqlSchemaDiff.Core 1.5.0

Suggested Alternatives

PeopleWorks.SqlSchemaDiff.Core

Additional Details

Renamed. This package continues as PeopleWorks.SqlSchemaDiff.Core from 1.6.0 onward —
same engine, same MIT licence, same repository (github.com/peopleworks/SqlSchemaDiff).
The SqlSchemaDiff.Core id receives no further updates. Change the PackageReference id;
no code changes are needed, the namespaces are unchanged.

dotnet add package SqlSchemaDiff.Core --version 1.5.0
                    
NuGet\Install-Package SqlSchemaDiff.Core -Version 1.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SqlSchemaDiff.Core" Version="1.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SqlSchemaDiff.Core" Version="1.5.0" />
                    
Directory.Packages.props
<PackageReference Include="SqlSchemaDiff.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SqlSchemaDiff.Core --version 1.5.0
                    
#r "nuget: SqlSchemaDiff.Core, 1.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SqlSchemaDiff.Core@1.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SqlSchemaDiff.Core&version=1.5.0
                    
Install as a Cake Addin
#tool nuget:?package=SqlSchemaDiff.Core&version=1.5.0
                    
Install as a Cake Tool

SqlSchemaDiff.Core

The SQL Server schema engine behind SQLDiff, packaged as a library so that every tool that needs it shares one implementation.

It extracts a database's structure, compares two structures, and generates the T-SQL that carries one to the shape of the other — emitting incremental ALTER TABLE statements that preserve the rows already in the table rather than rebuilding it.

Why this package exists

The engine used to be copied into each consumer. The copies drifted, and the drift was not cosmetic: one copy still compared tables as normalised text and could only offer a DROP/CREATE rebuild, while the other had moved on to column-level ALTER. The tool calling the stale copy silently lost the data-preserving behaviour that is the entire point.

One package, one behaviour, one place to fix a bug.

Install

dotnet add package SqlSchemaDiff.Core

Using it

using SqlSchemaDiff.Models;
using SqlSchemaDiff.Services;

// 1. read both sides
var extractor = new SqlServerSchemaExtractor();
var source = await extractor.ExtractAsync(sourceConnectionString, ct);
var target = await extractor.ExtractAsync(targetConnectionString, ct);

// 2. optionally narrow the comparison; filters must apply to BOTH sides,
//    or a skipped object looks target-only and a later drop would remove it
var filter = ObjectFilter.Parse(include: "table:", exclude: "dbo.Audit*");
source = filter.Apply(source);
target = filter.Apply(target);

// 3. compare — nothing is executed, you get a script back
var diff = new SchemaDiffer().Diff(
    source, target,
    includeDrops: false,          // target-only objects are reported, not dropped
    includeTableDrops: false,     // dropping whole tables needs this as well
    allowTableRebuild: false,     // refuse a rebuild rather than lose rows
    addOnly: false);              // true = only add what is missing

Console.WriteLine(diff.Script);

SqlBatchExecutor applies a script in a single transaction — if any batch fails the whole change rolls back — and AuditLogger records what ran.

What is in the box

Type Does
SqlServerSchemaExtractor Reads tables, columns, indexes, keys, constraints, views, procedures, functions and alias types into a DatabaseSnapshot
SchemaDiffer Compares two snapshots and composes the migration script, ordering objects by dependency
TableDiffer The data-preserving part: column-level ADD / ALTER COLUMN / DROP COLUMN
ObjectFilter [type:]glob include/exclude patterns, applied to both sides
SqlBatchExecutor · SqlBatchSplitter Splits on GO and applies in one transaction
SchemaTextNormalizer · SqlModuleRewriter · SqlRender Text normalisation and DDL rendering
ConnectionStringResolver · ConnectionVerifier Connection strings from a value, a file or env:NAME; connectivity checks

Safety defaults

Nothing is dropped unless asked. An object that exists only on the target is reported as a -- WARNING: comment and left in place; includeDrops enables removing them, and dropping whole tables needs includeTableDrops on top of that. A table that cannot be reconciled with ALTER alone is refused unless allowTableRebuild is set.

The namespaces are SqlSchemaDiff.*, matching the package: SqlSchemaDiff.Models and SqlSchemaDiff.Services.

MIT licensed. Built by PeopleWorks.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.0 119 8/30/2026 1.5.0 is deprecated.