Reputation: 5488
I know I can do :
Database.Migrate();
after the context is ready. But I cannot get EF to do it when initialising my context, like you could do previously with EF 6.1 using Database.SetInitializer
and MigrateDatabaseToLatestVersion
in the context constructor.
So, how can I ensure that the DB is created or updated and migrated using the available migrations before I make my first call to get data?
Upvotes: 2
Views: 309
Reputation: 41769
Just instantiate the DbContext during app startup, and call Database.Migrate()
Upvotes: 1