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:

db.Database.EnsureCreated()

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:

db.Database.Migrate();

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!

TypeScript is well worth a look

Anders Hejlsberg, the language designer integral to the development of C#, announced TypeScript last week. In summary, this is a superscript of Javascript that provides an optional way to introduce static typing to part or all of your Javascript to support the development process. It compiles down to Javascript and is fully compatible with Javascript hosts.

In a way, I think TypeScript was inevitable - it’s the clear evolution of tools like Clojure and CoffeeScript that themselves have made solid progress towards solving the problem of application scale javascript.

Microsoft’s timing is perfect for me. I am a strong proponent of SOA and have been more and more inclined as time has gone on to weave services in the UI as late as possible – but I’ve always found large javascript applications problematic to manage. TypeScript looks like it can really help take away a lot of the pain. I particularly like the virtual project system and the way you can provide idl like *.d.ts files to provide intellisense for pre-exisitng Javascript libraries.

If you do any kind of Javascript, do check it out.