LowCodeHub.Migration.SqlServer 0.0.1

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

LowCodeHub.Migration.SqlServer

LowCodeHub.Migration.SqlServer provides a simple startup migration runner for SQL Server using embedded .sql scripts and deterministic execution order.

What this package does

  • Runs SQL scripts from embedded resources.
  • Orders scripts by Unix timestamp prefix in file name.
  • Supports normal (journaled) scripts and always-execute scripts.
  • Fails fast on invalid script naming or missing scripts (by default).

Install

dotnet add package LowCodeHub.Migration.SqlServer

Quick Start

using LowCodeHub.Migration.SqlServer.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddMigration(builder.Configuration, sectionName: "Migration");

var app = builder.Build();

await app.RunDatabaseMigrationAsync<Program>(); // optional token overload exists

app.Run();

Configuration

{
  "Migration": {
    "ConnectionString": "Server=.;Database=MyDb;Trusted_Connection=True;Encrypt=False",
    "Directories": [ "MyApp.Migrations.Scripts" ],
    "AlwaysExecuteDirectories": [ "MyApp.Migrations.Always" ],
    "FailOnNoScriptsFound": true
  }
}

Script Naming Rules (Strict)

Scripts must start with a Unix-time numeric prefix:

  • Valid: 1766733156_create_users.sql
  • Valid: 1766733160_add_index.sql
  • Invalid: create_users.sql (no prefix)
  • Invalid: v1_create_users.sql (prefix not numeric)

If naming is invalid, migration throws with a clear format error.

Ordering

  • Ordering is based on the numeric prefix in the script file name.
  • Folder name is used only for filtering (which scripts to include), not for ordering.
  • If two scripts share the same numeric prefix, secondary ordering is by script name.

Journal vs Always Execute

  • Scripts in Directories are journaled (run once; tracked by DbUp journal).
  • Scripts in AlwaysExecuteDirectories run every startup (not journaled).

This is useful for:

  • permissions grants
  • view/procedure refresh scripts
  • maintenance scripts that should always re-apply

Failure and Transactions

  • Scripts execute one by one.
  • Each script runs in its own transaction.
  • If a script fails:
    • that script is rolled back
    • migration stops immediately
    • next scripts are not executed

Cancellation

You can pass an optional cancellation token:

await app.RunDatabaseMigrationAsync<Program>(app.Lifetime.ApplicationStopping);

Cancellation is checked between script executions.

Best Practices

  1. Keep script names immutable once merged.
  2. Use Unix seconds prefix for predictable order.
  3. Keep one concern per script (small and reversible where possible).
  4. Use AlwaysExecuteDirectories only for idempotent scripts.
  5. Keep FailOnNoScriptsFound = true in production.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
0.0.12 122 7/3/2026
0.0.11 125 6/23/2026
0.0.10 113 6/21/2026
0.0.3 129 5/18/2026
0.0.2 147 4/23/2026
0.0.1 914 3/26/2026