microsoft / microsoft/aspire-samples

DatabaseMigrations sample - no way to revert applied migrations?

Open
#577 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area-samples
Dominant language
C#
Stars
1.2k
Forks
345
Avg merge
3d 13h
Merged PRs (30d)
30

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?

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start with the DatabaseMigrations sample and its README, then reproduce the documented migrations remove and database update commands. Determine what guidance or sample configuration is missing for reverting an applied migration, and document a supported workflow whose completion can be verified against the reported connection-string error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
databases, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.