I can use package manager to run 'update-database -verbose' locally.
Probably a stupid question but I can't find it online - once my website is deployed - how can I run this manually on the server?
Secondarily - what other strategies would you recommend for deploying database migrations to production - and how would they be preferable?
Thanks
You have a couple of options:
update-database -script
to generate the SQL commands to update the database on the server/packages/EntityFramework5.0.0/tools/migrate.exe
. I've used it successfully in the past with Jet Brains' Team City Build Server to setup the migrations with my deploy scripts.Update: Also, check out Sayed Ibrahim's blog, he works on the MsBuild Team at Microsoft and has some great insights on deployments
I know that the question is already answered, but for future reference:
One of the options is to put something like this in the constructor of your DB context class:
public MyDbContext()
{
System.Data.Entity.Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyDbContext, Configuration>());
}
For us, the DBAs are the only group to have access to the production (and pre-production) environments. We simply use the Update-Database -Script
package console command to get the Sql required to update the database. This gets handed off to them where they can validate it, etc.
Maybe a little too simplistic for some but it works.
HTH.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With