2

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

3
  • Does this answer your question? How to unapply a migration in ASP.NET Core with EF Core Commented May 20, 2021 at 8:04
  • That example not working Commented 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 ? Commented May 20, 2021 at 8:12

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
1

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

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 ....

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.