Planning and SQL preview

A version plan answers what runs. SQL preview shows the supported operation SQL.

Examples use Classic and Fluent tabs. Your choice follows you through the manual.

Read-only version planning

Plan and DryRun inspect applied versions through IMigrationHistory without creating/upgrading history or invoking migration bodies, callbacks, transactions or SQLite PRAGMA changes. Set the same scope, tags and assembly you intend to deploy. The fragment below assumes an initialized runner.

Inspect version steps

Classic

var plan = runner.Plan(10);
foreach (var step in plan)
    Console.WriteLine($"{step.Version}: {(step.IsUp ? "up" : "down")}");
runner.DryRun = true;
runner.MigrateTo(10);

Fluent

var plan = runner.Plan(10);
foreach (var step in plan)
    Console.WriteLine($"{step.Version}: {(step.IsUp ? "up" : "down")}");
runner.DryRun = true;
runner.MigrateTo(10);

Shared host · both styles

Preview connected SQL

PreviewSql reads connected history and schema. Classic bodies require explicit opt-in; provider calls are captured through a proxy that rejects unsupported access. Fluent authoring builds operations directly. This is trusted C# execution in both cases, not a security sandbox.

Generate operation SQL

Classic

var sql = runner.PreviewSql(10, ProviderTypes.SQLite, allowLegacyBodies: true);
Console.WriteLine(sql);

Fluent

var sql = runner.PreviewSql(10, ProviderTypes.SQLite);
Console.WriteLine(sql);

Choose one authoring style

Offline generation and boundaries

MigrationSqlPreview.Generate can render supported operations without connecting; the CLI exposes --offline. Earlier structured create/rename operations update the planned schema. Raw SQL invalidates that knowledge, so later dependencies can fail.

Basic tables/columns, supported renames, simple indexes, inserts and raw SQL form the preview subset. Unsupported alterations, constraint changes, filters, callbacks and schema dependencies throw. InitializeOnce overrides are rejected rather than skipped silently. Post-commit callbacks do not run. Output contains operation SQL, not history guards or an idempotent deployment bundle.