1

I am using asp.net ef core and I have to remove specific migration from the migration folder. How can I do that?

manish
  • 11
  • 1
  • 3
  • Does this answer your question? [How to unapply a migration in ASP.NET Core with EF Core](https://stackoverflow.com/questions/38192450/how-to-unapply-a-migration-in-asp-net-core-with-ef-core) – CodeNotFound May 20 '21 at 08:04
  • That example not working – manish May 20 '21 at 08:09
  • What do you mean by specific in your question ? The last one, the first one or one that is applied after a lot migrations are done ? – CodeNotFound May 20 '21 at 08:12

3 Answers3

2

If u wanna delete your last migration after applying it to database use

Remove-Migration -Force

Or if u want to delete any particular migration then use

Remove-Migration "YourMigrationName" -Force

This worked for me.

Note : Be carefull and sure while removing any particular migration cz it might affect your database.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 27 '21 at 13:51
0

If U Wanna Deleted Your Last Migration You Can Use Remove-Migration but if you get this error **The migration Your Migration Name has already been applied to the database. ** this mean you use Update-Database and your migration add in database so if you wanna delete this migration you should find migration table in you Database and delete from migration table and delete any table you don't need that. and again use Remove-Database and this will work.

If your data isn't big so you can use this but be careful maybe your data you had save will delete ....

Amir Tahan
  • 107
  • 8
0

To remove the last migration type

Remove-Migration

from Visual Studio Powershell or

dotnet ef migrations remove

from the .NET Core CLI

.NET Documentation Managing Migrations

This is for EF version 6.0.10

You can get a list of migrations by typing

Get-Migration

Or dotnet ef migrations list from the CLI

Chris Catignani
  • 5,040
  • 16
  • 42
  • 49