brysonbw/dotnet-ef-scripts

A collection of handy scripts for .NET Entity Framework

0

stars

1

commits

Shell

primary language

Sep 13, 2026

updated

README

dotnet-ef-scripts

A collection of handy scripts for .NET Entity Framework Core migrations and database management.

Prerequisites

  • .NET SDK

  • dotnet-ef global tool installed:

    dotnet tool install --global dotnet-ef
    
  • Bash shell environment (macOS, Linux, or WSL / Git Bash on Windows)

Scripts

Copy and run these in your own folder path.

[!NOTE] Before running a script for the first time, open your terminal and make it executable by running:

chmod +x <folder-path>/<script-name>.sh

add-migration.sh

Description:

Adds a new Entity Framework Core migration and immediately applies it to the target database.

Usage:

./<folder-path>/add-migration.sh <migration-name> [project-path]

Parameters:

  • <migration-name> (Required): The name of the new migration (e.g., AddUserTable).
  • [project-path] (Optional): Path to the .NET project containing the DbContext/migrations. Defaults to ./src/Migrations.

Example:

./scripts/add-migration.sh AddUserTable ./src/MyProject

remove-migration.sh

Description:

Safely removes a migration from both the database and the codebase. It verifies the target migration exists in the migration history, rolls back the database to the preceding migration state (or state 0 if removing the initial migration), and removes the migration from code.

Usage:

./<folder-path>/remove-migration.sh <migration-name-to-remove> [project-path]

Parameters:

  • <migration-name-to-remove> (Required): The name of the migration to remove.
  • [project-path] (Optional): Path to the .NET project containing the DbContext/migrations. Defaults to ./src/Migrations.

Example:

./scripts/remove-migration.sh AddUserTable ./src/MyProject

License

MIT License

Contributors

brysonbw

1 commits

brysonbw/dotnet-ef-scripts

A collection of handy scripts for .NET Entity Framework

0

stars

1

commits

Shell

primary language

Sep 13, 2026

updated

README

dotnet-ef-scripts

A collection of handy scripts for .NET Entity Framework Core migrations and database management.

Prerequisites

  • .NET SDK

  • dotnet-ef global tool installed:

    dotnet tool install --global dotnet-ef
    
  • Bash shell environment (macOS, Linux, or WSL / Git Bash on Windows)

Scripts

Copy and run these in your own folder path.

[!NOTE] Before running a script for the first time, open your terminal and make it executable by running:

chmod +x <folder-path>/<script-name>.sh

add-migration.sh

Description:

Adds a new Entity Framework Core migration and immediately applies it to the target database.

Usage:

./<folder-path>/add-migration.sh <migration-name> [project-path]

Parameters:

  • <migration-name> (Required): The name of the new migration (e.g., AddUserTable).
  • [project-path] (Optional): Path to the .NET project containing the DbContext/migrations. Defaults to ./src/Migrations.

Example:

./scripts/add-migration.sh AddUserTable ./src/MyProject

remove-migration.sh

Description:

Safely removes a migration from both the database and the codebase. It verifies the target migration exists in the migration history, rolls back the database to the preceding migration state (or state 0 if removing the initial migration), and removes the migration from code.

Usage:

./<folder-path>/remove-migration.sh <migration-name-to-remove> [project-path]

Parameters:

  • <migration-name-to-remove> (Required): The name of the migration to remove.
  • [project-path] (Optional): Path to the .NET project containing the DbContext/migrations. Defaults to ./src/Migrations.

Example:

./scripts/remove-migration.sh AddUserTable ./src/MyProject

License

MIT License

Contributors

brysonbw

1 commits

Languages

Shell

100.0%