UmbrellaFrame.ModelSync.SQLite 1.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package UmbrellaFrame.ModelSync.SQLite --version 1.5.0
                    
NuGet\Install-Package UmbrellaFrame.ModelSync.SQLite -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="UmbrellaFrame.ModelSync.SQLite" Version="1.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UmbrellaFrame.ModelSync.SQLite" Version="1.5.0" />
                    
Directory.Packages.props
<PackageReference Include="UmbrellaFrame.ModelSync.SQLite" />
                    
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 UmbrellaFrame.ModelSync.SQLite --version 1.5.0
                    
#r "nuget: UmbrellaFrame.ModelSync.SQLite, 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 UmbrellaFrame.ModelSync.SQLite@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=UmbrellaFrame.ModelSync.SQLite&version=1.5.0
                    
Install as a Cake Addin
#tool nuget:?package=UmbrellaFrame.ModelSync.SQLite&version=1.5.0
                    
Install as a Cake Tool

ModelSync

ModelSync

NuGet CI License

ModelSync is a schema and migration toolkit for .NET projects that want explicit database changes without adopting a full ORM. It generates provider-specific DDL from attributed C# models, compares models with live databases, runs ordered SQL migrations, synchronizes stored procedures, and produces deployment reports.

ModelSync keeps framework SQL in Core. Provider packages contribute structured capabilities and ADO.NET execution adapters; they do not maintain separate create, reset, catalog, history, or lock SQL engines.

It is not limited to CREATE TABLE and ALTER TABLE. The migration runner owns ordered table, routine, trigger, seed, and custom SQL artifacts and records their history and hashes. Data migration is intentionally SQL-first: use reviewed seed or CustomSql scripts for transformations. ModelSync does not generate EF-style C# Up/Down classes or promise automatic rollback.

Relationship support is schema-focused. Keys, composite keys, unique constraints, indexes, foreign keys, defaults, and checks are represented in the plan when supported by the provider. Runtime navigation loading, LINQ, change tracking, and CRUD remain the responsibility of Dapper, ADO.NET, EF Core, or another data-access layer.

Current version: 1.5.0

Read the 1.5.0 release notes and the 1.4.0-to-1.5.0 migration guide before upgrading a production migration job.

What's New in 1.5.0

Version 1.5.0 adds deterministic schema evidence, review-only rename intent, composite relational metadata, safer semantic drift comparison, and migration-backed safe apply. Existing generator and migration API signatures remain available.

Choose A Workflow

Goal API
Generate table SQL from a model TableGenerator
Compare models with a live database ModelSynchronizer
Run ordered SQL files with history MigrationRunner
Synchronize procedure files StoredProcedureSynchronizer
Validate, preview, and run from CI modelsync CLI

Install

Install the provider you need. Core is included automatically.

dotnet add package UmbrellaFrame.ModelSync.SqlServer --version 1.5.0
dotnet add package UmbrellaFrame.ModelSync.MySql --version 1.5.0
dotnet add package UmbrellaFrame.ModelSync.PostgreSQL --version 1.5.0
dotnet add package UmbrellaFrame.ModelSync.SQLite --version 1.5.0
dotnet add package UmbrellaFrame.ModelSync.Oracle --version 1.5.0
dotnet add package UmbrellaFrame.ModelSync.Analyzers --version 1.5.0

UmbrellaFrame.ModelSync.Oracle is publicly available as a preview provider for table DDL and partial safe model synchronization. Its migration runner, routine synchronization, reset, and native lock features are not production-ready.

Quick Start

using UmbrellaFrame.ModelSync.Core;
using UmbrellaFrame.ModelSync.SqlServer;

[SqlServerTableName("Products")]
public sealed class Product
{
    [SqlServerColumnType(SqlServerColumnType.INT)]
    [SqlServerColumnPrimaryKey(isAutoIncrement: true)]
    public int Id { get; set; }

    [SqlServerColumnType(SqlServerColumnType.NVARCHAR, "200")]
    [SqlServerColumnNotNull]
    [DbColumnIndex("IX_Products_Name")]
    public string Name { get; set; } = string.Empty;
}

var generator = new SqlServerTableGenerator(connectionString);
var sql = generator.GenerateSqlServerTable<Product>(ifNotExists: true);

Console.WriteLine(sql);
await generator.CreateTablesAsync();

Generate first, inspect the SQL, then execute. Destructive methods require explicit approval:

var allow = DestructiveOperationOptions.Allow();
generator.DropColumn<Product>("LegacyCode", allow);
generator.AlterColumnType<Product>("Price", allow);
await generator.DropTablesAsync(allow);

Live Model Comparison

var options = new SqlServerModelSyncOptions
{
    ConnectionString = connectionString,
    DefaultSchema = "app",
    HistorySchema = "sec"
};

var result = await SqlServerModelSynchronizer
    .FromAssemblies(options, typeof(Product).Assembly)
    .CompareAsync(cancellationToken);

// Review AutomaticOperations, ManualOperations, SkippedOperations,
// and BlockedOperations before applying.
await result.ApplyAsync(cancellationToken);

On SQL Server, MySQL/MariaDB, PostgreSQL, and SQLite, ApplyAsync() and ApplyWithResultAsync() route automatic safe operations through the migration runner. This gives model-driven changes the same ordering, lock, transaction, history/hash, and structured-result lifecycle as registered scripts. CompareAsync() remains read-only. Oracle preview retains its limited direct execution path.

Create review artifacts before applying:

var markdown = ModelSyncPlanMarkdownReport.Create(result);
var json = ModelSyncPlanJsonReport.Create(result);

ModelSync reports changed default and check expressions for manual review instead of silently replacing constraints. Plan SQL previews are bounded and redact literal values.

Schema evidence and advanced metadata

The snapshot, rename-hint, and table-level composite metadata APIs below are part of the stable 1.5.0 package contract.

SchemaSnapshotFactory provides deterministic model/live/baseline snapshot contracts for tooling; a snapshot is evidence, not automatic rollback permission.

Provider synchronizers can produce the canonical snapshots directly:

var synchronizer = SqlServerModelSynchronizer
    .FromAssemblies(options, typeof(Product).Assembly);

var modelSnapshot = synchronizer.CreateModelSnapshot(sourceCommit: gitCommit);
var liveSnapshot = await synchronizer.CreateDatabaseSnapshotAsync(
    asBaseline: true,
    sourceCommit: gitCommit,
    cancellationToken);

These calls do not mutate the database. A baseline labels review evidence; it does not authorize rollback.

Drift hash comparison is intended for an approved live-database baseline and a later live snapshot from the same provider and scope. A model snapshot is separate design evidence and is not hash-interchangeable with a live snapshot; the CLI rejects that mixed comparison. ModelSync-created checks use deterministic CK_<Table>_<Column> names to support second-run convergence. Custom-named checks remain review-required.

Safe additive operations can be automatic. Drop, rename, narrowing, and risky nullability changes are reported instead of silently executed.

For a deliberate property rename, [DbPreviousColumnName("OldCode")] produces a review-only RenameColumn plan when the old column exists. ModelSync does not guess or automatically execute renames.

DbTableIndex and DbTableForeignKey add ordered composite index/FK metadata while existing property attributes remain compatible. Include, filter, sort, and referential-action options are capability checked; unsupported combinations are blocked, not silently simplified.

Ordered Migrations

var runner = new SqlServerMigrationRunner(connectionString);

runner.RegisterScriptFile("Database/Scripts/Tables/001_CreateProducts.sql");
runner.RegisterScriptFile("Database/Scripts/StoredProcedures/010_GetProducts.sql");
runner.RegisterScriptFile("Database/Scripts/Seeds/020_DefaultProducts.sql");

var plan = await runner.CompareRegisteredAsync(cancellationToken); // read-only
var result = await runner.RunWithResultAsync(cancellationToken);

Scripts run in this order:

Tables -> StoredProcedures -> Triggers -> Seeds -> CustomSql

History rows and SQL hashes make repeat runs predictable. Registered SQL files are trusted project artifacts; do not build them from user input.

CLI And Reports

The CLI supports sqlserver, mysql, mariadb, postgresql, and sqlite. Oracle is intentionally unavailable in the CLI while its migration runner remains preview-only.

dotnet tool install --global UmbrellaFrame.ModelSync.Cli --version 1.5.0

Pass secrets through an environment variable instead of a process argument:

export MODELSYNC_CONNECTION_STRING='Data Source=modelsync-preview.db'

modelsync validate --scripts ./Database/Scripts

modelsync run \
  --provider sqlite \
  --connection-env MODELSYNC_CONNECTION_STRING \
  --scripts ./Database/Scripts \
  --dry-run

modelsync run \
  --provider sqlite \
  --connection-env MODELSYNC_CONNECTION_STRING \
  --scripts ./Database/Scripts \
  --apply \
  --report-md ./artifacts/modelsync-report.md \
  --report-json ./artifacts/modelsync-report.json

--apply is required for mutation. Ctrl+C is forwarded to the migration operation. The inline --connection option is retained for compatibility but may be visible in process listings.

Safety Notes

  • ModelSync is not an ORM and does not provide entity tracking, LINQ, or runtime CRUD.
  • Compare APIs are read-only; infrastructure is created by explicit mutation APIs.
  • DbColumnDefault, DbColumnCheck, and migration scripts contain reviewed SQL and must not use untrusted input.
  • Prefer a deployment-time migration job. If startup migration is unavoidable, keep provider-native locking enabled.
  • Database reset requires explicit destructive approval, an expected database name, environment validation, and system-database protection.
  • Run database reset from a single deployment/local runner; do not start multiple application instances with reset enabled.
  • SQL Server can optionally back up a database before reset.

Provider Snapshot

Feature SQL Server MySQL/MariaDB PostgreSQL SQLite Oracle preview
Table DDL Yes Yes Yes Yes Yes
Safe model sync Yes Yes Yes Yes Partial
Migration runner Yes Yes Yes Yes No
Stored procedures Yes Yes Yes No No
Native migration lock Yes Yes Yes Write lock No

Documentation

MIT © UmbrellaFrame

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.1 150 8/9/2026
1.5.0 115 8/9/2026
1.4.0 133 7/18/2026
1.4.0-rc.1 81 7/18/2026
1.3.0 126 7/15/2026
1.2.3 124 7/11/2026
1.2.2 134 7/1/2026
1.2.0 142 6/29/2026
1.1.0 138 6/29/2026
1.0.8 135 6/28/2026
1.0.7 132 6/24/2026
1.0.5 130 6/19/2026
1.0.4 127 5/22/2026
1.0.2 122 5/14/2026

ModelSync 1.5.0 adds schema snapshots, deterministic check convergence, composite metadata, and safer SQLite drift reporting.