EF Migrations Command Reference

Entity Framework is always a pain the back side when it comes to managing multiple database and know what to do if things get out of sync, an article by Anders Abel clearly lays out what need to be done and what can be used to sort out any sync problems, here is a snip from his article:

Entity Framework Migrations are handled from the package manager console in Visual Studio. The usage is shown in various tutorials, but I haven’t found a complete list of the commands available and their usage, so I created my own. There are four available main commands.

  • Enable-Migrations: Enables Code First Migrations in a project.
  • Add-Migration: Scaffolds a migration script for any pending model changes.
  • Update-Database: Applies any pending migrations to the database.
  • Get-Migrations: Displays the migrations that have been applied to the target database.

There are also three extra commands that are used by NuGet packages that install Entity Framework providers. These commands are not usually used as part of normal application development.

Original post from Anders Abel,

  • If you want to share my work from my blog you need to quote clearly where you got it from.

    • bryan@ind-igo.co.uk

      Morning Anders, sorry I normally do add a reference to the original work, I have added it to my post. Let me know if it is okay or if you need any further reference?

      • That looks fine to me. Thanks for updating.