Monday, October 6, 2014

Enabling Migrations in Entity Framework to update the database programatically

Migrations

Implementing migrations in entity framework

  • Open the Package Manager Console (Tools -> Library Package Manager -> Package Manager Console)
  • Select the project where the entity framework DataContext is contained and then in the console type Enable-Migrations
  • use the following code to update the migrations
  • Now a call to the migrate method on the migrator will result in the database being updated automatically to the current version