Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
herzkoenig opened this issue Nov 18, 2024 · 0 comments
Open

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

herzkoenig opened this issue Nov 18, 2024 · 0 comments

Comments

@herzkoenig
Copy link

herzkoenig commented Nov 18, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant