Skip to content

DatabaseMigrations sample - no way to revert applied migrations? #577

Open
@herzkoenig

Description

I'm relatively new to EF Core, so I might be missing something obvious, but it seems that with the DatabaseMigrations sample, reverting to a previous state after a migration has already been applied isn't straightforward.

In the README, it states:

To remove the unapplied migration, you need to run dotnet ef migrations remove --force. The --force switch tells the tool to avoid connecting to the database.

Without the --force switch, you encounter the error: "The ConnectionString property has not been initialized."

The same issue occurs when using dotnet ef database update <old-migration>, and with update, a --force doesn't exist and wouldn't make sense.

What would you recommend as the best way to revert back to a previous migration?

Would it be better to create SQL scripts, execute them manually for the desired migration, and then delete the migrations that come after the target one?

Is there a simple way to configure the ConnectionString for such purposes?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions