Automatically Creating a Database When Using EF Code First CTP5

I’ve been messing about with the new Entity Framework Code First CTP5 that was released recently. One thing that’s not obvious from the Gu’s blog post is how to automatically create your database if your not using SQLServer Express or Compact Edition.

Adding the following code you your Application_Start event in Global.ascx.cs seems to do the trick:

MyDbContextClass myDb = new MyDbContextClass();