For some reason my DB is not being created and i’m not getting any errors. I’m using “SQL Server”
Tring to initialize the DB in the global.asax.ca file:
protected void Application_Start(object sender, EventArgs e)
{
//BREAKPOINT HITS. GOOD
Database.SetInitializer<MenuManagerContext>(new MenuManagerServiceInitializer());
}
…
public class MenuManagerServiceInitializer : CreateDatabaseIfNotExists<MenuManagerContext>
{
//BREAKPOINT NEVER HITS. BAD
protected override void Seed(MenuManagerContext context)
{
context.Chains.Add(...);
context.SaveChanges();
base.Seed(context);
}
}
Any ideas why the database is not being created? I’m not even getting errors so it’s very hard to tell what is wrong…
Database.SetInitializerdoesn’t cause the database to be created. It’s only setting the initialization strategy.The DB is created if you are using a context for the very first time, for instance by issuing any query, or by attaching or adding an object to the context, and so on.