1

When I started a new EF Core project and wanner to create a new database, I made a mistake that wrote a wrong database name in connection string. Then I ran add-migration and update-database. And then I found the migration had applied to an existing database.

I attempted to revert this apply. But it's the first migration script of project. I don't know how to revert.

I would appreciate it if you could give me any suggestions.

Monody
  • 21
  • 4
  • https://stackoverflow.com/questions/38192450/how-to-unapply-a-migration-in-asp-net-core-with-ef-core#:~:text=To%20revert%20the%20last%20applied,snapshot%3A%20PM%3E%20Remove%2DMigration – Neil W May 01 '22 at 10:27
  • Thank but the migration I want to revert is the first, there's not a "prior-migration-name" to run update-database. – Monody May 01 '22 at 10:54

1 Answers1

1

I had founded the answer: just run update-database -migration:0. That could revert the frist applied migration. Then the first migration script would be able to be removed.

Monody
  • 21
  • 4