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

ef-code-first ef-migrations entity-framework entity-framework-6

Question

Is there a method for me to rename the code-first entity framework migration I developed and deployed to the database?

1
4
6/23/2017 8:46:58 AM

Accepted Answer

You cannot rename after applying a migration to Database. However, you may remove one migration and add another with the same or a different name.

First reset the migration to last migration

  PM>  update-database -TargetMigration:{lastmigrationname}

if this migration is the first, then

  PM>  update-database -TargetMigration:0

Remove the source code's current migration and any related files.

Add the migration with the desired name.

 PM>  add-migration {MigrationName}

then apply the newly prepared migration to the database.

 PM> update-database {MigrationName}
10
8/18/2016 6:57:24 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow