Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I rename the last entity framework migration applied on the database

I have created a code -first entity framework migration and applied to the database, is there a way I can rename this migration ?

like image 810
Kiran R Avatar asked Aug 18 '16 16:08

Kiran R


1 Answers

You cannot rename after applying a migration to Database. But you can delete and add another migration with same name or other name.

First reset the migration to last migration

  PM>  update-database -TargetMigration:{lastmigrationname}

If this is the first migration then

  PM>  update-database -TargetMigration:0

Delete the existing migration and relevant files from the source code

Add the migration using the name you want

 PM>  add-migration {MigrationName}

Then update the database with new migration created

 PM> update-database {MigrationName}
like image 94
Venky Avatar answered Sep 22 '22 14:09

Venky