manish
manish

Reputation: 21

How remove particular migration from migration folder in asp.net ef core

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

Upvotes: 2

Views: 14607

Answers (3)

Chris Catignani
Chris Catignani

Reputation: 5306

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

Upvotes: 1

Sharique Ansari
Sharique Ansari

Reputation: 21

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.

Upvotes: 2

Amir Tahan
Amir Tahan

Reputation: 129

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

Upvotes: 0

Related Questions