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
Post a Comment