Upgrading existing migrations

Update source definitions while preserving the history your databases already contain.

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

Explicit column attributes

Replace old ColumnProperty flags with IsNullable, IsIdentity and IsUnsigned. Primary, unique, foreign and check constraints belong to the table. GetColumns returns column attributes; use GetTableConstraints for key membership and ordered columns.

Keep the same applied migration versions and effective scope when recompiling. Do not create a new history table merely to make an incompatible source assembly run. Verify the upgrade against a restored database and a fresh database.

One fluent authoring surface

FluentMigration.BuildUp/BuildDown replaces the duplicate legacy builder. Use complete table definitions for keys, explicit operations for indexes, and independent foreign-key update/delete actions. Classic Up/Down migrations remain first-class.

CreateUsers.cs

Classic

using System.Data;
using DotNetProjects.Migrator.Framework;

[Migration(1)]
public class CreateUsers : Migration
{
    public override void Up()
    {
        Database.AddTable("Users",
            new Column("Id", DbType.Int32) { IsNullable = false },
            new Column("Name", DbType.String, 255),
            new PrimaryKeyConstraint("PK_Users", "Id"));
    }

    public override void Down() => Database.RemoveTable("Users");
}

Fluent

using DotNetProjects.Migrator.Framework;
using DotNetProjects.Migrator.Framework.Fluent;

[Migration(1)]
public class CreateUsers : FluentMigration
{
    public override void BuildUp(MigrationBuilder migration)
    {
        migration.Create.Table("Users")
            .WithColumn("Id").AsInt32().NotNullable()
            .WithColumn("Name").AsString(255)
            .WithPrimaryKey("PK_Users", "Id");
    }

    public override void BuildDown(MigrationBuilder migration)
        => migration.Delete.Table("Users");
}

Choose one authoring style

Behavior changes to review

Column changes preserve explicit uniqueness; old SQL Server ownership markers no longer control deletion. TimeSpan inputs mean intervals, so convert clock-time inputs to TimeOnly. SQLite GUID defaults use the same blob representation as inserted parameters; unrelated rebuilds preserve existing text defaults.

Read the complete compatibility migration guide for constructor replacements, custom-provider contracts, identity, constraint metadata and collation mappings. Version-specific details live there; these chapters describe the current API.