Nabs.Launchpad.Core.MigrationsCli 10.0.221

Prefix Reserved
dotnet add package Nabs.Launchpad.Core.MigrationsCli --version 10.0.221
                    
NuGet\Install-Package Nabs.Launchpad.Core.MigrationsCli -Version 10.0.221
                    
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="Nabs.Launchpad.Core.MigrationsCli" Version="10.0.221" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nabs.Launchpad.Core.MigrationsCli" Version="10.0.221" />
                    
Directory.Packages.props
<PackageReference Include="Nabs.Launchpad.Core.MigrationsCli" />
                    
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 Nabs.Launchpad.Core.MigrationsCli --version 10.0.221
                    
#r "nuget: Nabs.Launchpad.Core.MigrationsCli, 10.0.221"
                    
#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 Nabs.Launchpad.Core.MigrationsCli@10.0.221
                    
#: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=Nabs.Launchpad.Core.MigrationsCli&version=10.0.221
                    
Install as a Cake Addin
#tool nuget:?package=Nabs.Launchpad.Core.MigrationsCli&version=10.0.221
                    
Install as a Cake Tool

Nabs Launchpad Core Migrations CLI Library

⚠️ Warning: This package depends on prerelease packages and is intended for development and testing purposes. Use with caution in production environments.

A .NET 10 console application library for managing Entity Framework Core database migrations with an interactive terminal interface using Spectre.Console.

Overview

The Nabs.Launchpad.Core.MigrationsCli library provides a command-line interface for managing database migrations and schema changes. It offers both interactive menu-driven and command-line argument modes for flexibility in development and CI/CD workflows.

Key Features

  • List Migrations: Display all DbContexts with their outstanding model changes, migration history, and seed data processors
  • Add Migrations: Create new migrations for DbContexts with pending model changes
  • Remove Migrations: Remove the last migration from a DbContext (in progress)
  • Reset All Migrations: Delete all migrations and start over (in progress)
  • Apply Migrations: Apply pending migrations to the local database
  • Drop Database: Drop the design-time database with confirmation prompts
  • Interactive Menu: User-friendly terminal menu using Spectre.Console
  • Risk Analysis: Classify pending model changes by risk level (high, medium, low)

Getting Started

To use the Nabs Launchpad Core Migrations CLI library, follow these steps:

1. Create a Console Application

Create a new console application project in your .NET solution:

dotnet new console -n MyProject.MigrationsCli

2. Add Required References

Reference the Nabs.Launchpad.Core.MigrationsCli library in your console application project:

<ItemGroup>
  <ProjectReference Include="..\Nabs.Launchpad.Core.MigrationsCli\Nabs.Launchpad.Core.MigrationsCli.csproj" />
  <ProjectReference Include="..\MyProject.Migrations\MyProject.Migrations.csproj" />
</ItemGroup>

3. Configure Program.cs

Add the following code to your Program.cs file:

using Nabs.Launchpad.Core.MigrationsCli;

var migrationsConsole = new MigrationsConsole();

// Register your DbContext, SeedDataProcessor, and DesignTimeDbContextFactory
migrationsConsole.AddMigration<MyDbContext, MySeedDataProcessor, MyDesignTimeDbContextFactory>("myDatabaseConnection");

// Add additional DbContexts as needed
migrationsConsole.AddMigration<AnotherDbContext, AnotherSeedDataProcessor, AnotherDesignTimeDbContextFactory>("anotherDatabaseConnection");

await migrationsConsole.RunAsync(args);

4. Create Supporting Classes

Ensure you have a migrations project with:

  • DbContext: Your Entity Framework Core database context
  • IDesignTimeDbContextFactory: For design-time DbContext creation (required)
  • ISeedDataProcessor: For seeding initial or test data

Commands

List Migrations (list-migrations)

Display the current state of migrations for all registered DbContexts:

dotnet run -- list-migrations

This command shows:

  • Outstanding Model Changes: Pending changes with risk level indicators
    • 🚩 High risk (destructive operations like dropping tables/columns)
    • ⚠️ Medium risk (altering columns, adding/dropping foreign keys)
    • ✅ Low risk (adding columns/tables)
  • Migration History: Applied and pending migrations with timestamps
  • Seed Data Processors: Registered seed data processors for each DbContext

Add Migrations (add-migrations)

Create a new migration for DbContexts with pending model changes:

dotnet run -- add-migrations
dotnet run -- add-migrations --context PrimaryDbContext --migrationName AddCustomerTable

In interactive mode, you will be prompted to enter a migration name. In non-interactive mode, the --migrationName parameter is required.

Apply Migrations (apply-migrations)

Apply pending migrations to the database:

dotnet run -- apply-migrations
dotnet run -- apply-migrations --context PrimaryDbContext
dotnet run -- apply-migrations --context PrimaryDbContext --migrationName InitialCreate

Note: If there are pending model changes that haven't been added as migrations, the command will warn you and skip that DbContext.

Remove Migrations (remove-migrations)

Remove the last migration from a DbContext:

dotnet run -- remove-migrations
dotnet run -- remove-migrations --context PrimaryDbContext

Reset Migrations (reset-migrations)

Delete all migrations and start fresh:

dotnet run -- reset-migrations
dotnet run -- reset-migrations --project MyProject.DataMigrations

Drop Database (drop-db)

Drop the design-time database (requires confirmation):

dotnet run -- drop-db
dotnet run -- drop-db --context PrimaryDbContext

This command will:

  1. Check if the database exists before attempting to drop
  2. Prompt for confirmation before dropping each database
  3. Display success or skip messages for each operation

Interactive Mode

Running the application without arguments launches an interactive menu:

dotnet run

This displays a menu with options:

  1. List Migrations
  2. Add Migrations
  3. Apply Migrations
  4. Remove Migrations
  5. Reset Migrations
  6. Drop Database (only works for IDesignTimeDbContextFactory)
  7. Exit

Dependencies

  • .NET 10: Target framework
  • Microsoft.EntityFrameworkCore: Core EF abstractions
  • Microsoft.EntityFrameworkCore.SqlServer: SQL Server provider
  • Microsoft.Extensions.Hosting: Hosting abstractions
  • Spectre.Console: Rich console output and interactive menus
  • Spectre.Console.Cli: Command-line argument parsing
  • Nabs.Launchpad.Core.Migrations: Core migration interfaces

Risk Classification

The CLI analyzes pending model changes and classifies them by risk level:

Operation Risk Level Icon
Drop Table High 🚩
Drop Column High 🚩
Rename Table High 🚩
Add Foreign Key (with CASCADE delete) High 🚩
Alter Column Medium ⚠️
Add Column (non-nullable without default) Medium ⚠️
Add Foreign Key Medium ⚠️
Drop Foreign Key Medium ⚠️
Create Table Low
Add Column (nullable or with default) Low
Create Index Low
Ensure Schema Low

Work In Progress

The following features are currently under development:

  • Remove Migrations Command: Implementation for removing last migration
  • Reset Migrations Command: Implementation for resetting all migrations
  • Context Filtering: Filter commands by specific DbContext name
  • Migration Name Filtering: Apply specific migrations by name

Integration with Launchpad

This library is part of the Nabs Launchpad framework and works with:

  • Core.Migrations: Provides ISeedDataProcessor and IMigrationsProcessor interfaces
  • Core.Persistence: Works with Entity Framework DbContext configurations

Best Practices

  1. Use Design-Time Factories: Implement IDesignTimeDbContextFactory<TDbContext> for reliable DbContext creation (required for registration)
  2. Review Risk Analysis: Always review the risk classification before applying migrations
  3. Backup Before Destructive Operations: High-risk operations may result in data loss
  4. Test Migrations Locally: Apply migrations to a local database before production
  5. Use Interactive Mode for Development: The menu-driven interface is ideal for development workflows
  6. Check for Pending Model Changes: The apply-migrations command will warn you if there are uncommitted model changes

License

Copyright © Net Advantage Business Solutions

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
10.0.221 49 2/3/2026
10.0.220 51 1/14/2026
10.0.219 64 1/5/2026
10.0.218 60 1/4/2026
10.0.217 76 1/4/2026 10.0.217 is deprecated because it is no longer maintained.
10.0.216 80 1/4/2026 10.0.216 is deprecated because it is no longer maintained.