I have a 3-tier architecture project (Web, Service, DataAccess), I just want to migrate the database to latest version whenever POCO changes happen. We can do this by calling the automatic migration code from Application_Start
event. In this scenario, I don't have the reference of the DataAccess
project in my web. So how can I call the automatic migration code from Application_Start
event?
Database.SetInitializer(new MigrateDatabaseToLatestVersion<BlogContext, Configuration>());
I can't access the BlogContext
from Application_Start
.
Please help me
Thanks in advance [In Production environment, we can't run update-database command thru VS, so is there any other way to update the database automatically)
DataAcess
project. If it doesn't, and you have some other "business layer" in between, then define a function in the business layer that does the migration, and call that from the Web Project.