Fix for Entity Framework 7 Migration Problem in Shawn Wildermuth’s ASP.NET 5 Pluralsight Sourse

Shawn Wildermuth posted a great ASP.NET 5 course up at Pluralsight here.

This post is a quick fix to a problem I ran into updating the database in the ASP.NET Identity Section. Note – I have been using the RC1-Final version of ASP.NET 5.

When you try to run the project so that it migrates the identity schema into the database, migration fails. The reason is that originally the database was created in the `Startup.cs` class with a call to:


This will prevent migrations from working because it doesn’t (by design) create the necessary system generated __EFMigrationsHistory table in the DB. If you change this line of code to:


then everything works (at least for me) because with this code, when the database is first created the migrations table will be added. Note you will need to have created the database via this method in the first place – you can’t add/change this line of code after the DB is already created as the migrations table can’t be added retrospectively. If this is where you are, you have no easy option but to drop and recreate the DB. Also, you will need to manually add samhastings as the username in the two existing Trips in the DB, since the migration code doesn’t account for this.

Julie Lerman posted on this in a lot more detail here. Hope this helps!