views:

65

answers:

0

I'm not having any luck finding where in my code I should run migrations when I start up my application. Obviously this should only happen once, when the app starts.

In Global.asax.cs I tried:

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();

    RegisterRoutes(RouteTable.Routes);

    var repository = new SimpleRepository("MyConnection", SimpleRepositoryOptions.RunMigrations);
}

but new columns are not created if I modify model objects.

If I initialize the repository in the controller constructor it works just fine, but running migrations every time a controller object is created isn't the right ... where should I initialize the repository to have it happen just once, but to make sure it happens when I start my application, or should I run migrations before starting the app?