I am using asp.net ef core and I have to remove specific migration from the migration folder. How can I do that?
-
Does this answer your question? How to unapply a migration in ASP.NET Core with EF CoreCodeNotFound– CodeNotFound2021-05-20 08:04:29 +00:00Commented May 20, 2021 at 8:04
-
That example not workingmanish– manish2021-05-20 08:09:16 +00:00Commented May 20, 2021 at 8: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– CodeNotFound2021-05-20 08:12:06 +00:00Commented May 20, 2021 at 8:12
3 Answers
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 Comment
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
Comments
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 ....