Note to self: DropCreateDatabaseIfModelChanges during development

While developing using Entity Framework, code first, I should add the following to Global.asax:

protected void Application_Start()
    #if DEBUG
    Database.SetInitializer(new DropCreateDatabaseIfModelChanges<DbCtx>());
That way, given that that the models have changed, when I am running the application in debug mode, the database will be dropped and recreated.

1 comment:

  1. How do you DropCreateDatabaseIfModelChanges if database is currently in use?