Entity Framework: How to upgrade or downgrade during migration -


this migration code addisdefault. tell me how down grade later after upgrade , again upgrade later. command need issue @ package manager console.

public partial class addisdefault : dbmigration     {         public override void up()         {             addcolumn("dbo.contacts", "isdefault", c => c.boolean(nullable: false));         }          public override void down()         {             dropcolumn("dbo.contacts", "isdefault");         }     } 

you don't need downgrade here.if don't need isdefault column remove on model , run migration again shown below.

pm> add-migration "remove_isdefault"  pm> update-database 

later if need add again,change model , run again new change.very simple :)

update :

on package manager console :

pm> update-database –targetmigration: yourmigrationscriptname  

reference : code first migrations


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -