Reputation: 16430
I'm in the process of adding new fields, on my class but I've noticed the table won't be created until I save an object of that class. It's a bit annoying, is there a way to force it to create that table on App start or something?
Upvotes: 1
Views: 176
Reputation: 32447
You can force the initializer at Application_Start
by
protected void Application_Start()
{
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<MyContext>());
(new MyContext()).Database.Initialize(true);
}
Upvotes: 2
Reputation: 101
I think you can use Repository and Unit of Work patterns.
Using Repository and Unit of Work patterns with Entity Framework 4.0
which the Save method is defined in IUnitOfWork interface.
public interface IUnitOfWork
{
void Save();
}
Upvotes: 1