Specific Rollback command line tool

Open
#16,378 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, sql
Domain
cli, database

Research direction

Start with the existing dotnet ef database update -migration NameOfMigration behavior and the migration version recorded in the _Migrations table. Review how rollback and data-loss handling should work with the SQL Server provider, then define the scope of a dedicated dotnet ef database rollback command and a way to inspect the current migration version.

Written by the indexing model from the issue text.

Description

area-tools customer-reported

Describe what is not working as expected.
If I attempt to run a dotnet ef database update -migration NameOfMigration and it would result in dataloss (i.e it wants to perform a Down action), action should be cancelled to prevent possible accidental dataloss.
Suggestion:
Instead introduce a dotnet ef database rollback command specifically for rolling back migrations.
This is how some other db management tools work, like ActiveRecord in rails.
This is especially useful as there appears to be no CLI tool to check the current DB migration version, based on the _Migrations table that is updated by EF. Checking the current DB version at the moment requires I open a new code window, set syntax to SQL, connect to the DB and issue the select command to the appropriately named table

Further technical details

EF Core version: Entity Framework Core .NET Command-line Tools, 2.2.4-servicing-10062
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: macOS 10.14.5
IDE: Code + Terminal

Dominant language
C#
Stars
14.8k
Forks
3.4k
Avg merge
2d 5h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.