ASP.NET MVC 4, Migrations - How to run 'update-database' on a production server

前端 未结 7 886
Happy的楠姐
Happy的楠姐 2021-01-31 04:02

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 r

7条回答
  •  终归单人心
    2021-01-31 04:16

    I personally like to setup automatic migrations that run every time the application's start method is called. That way with every deployment you make you have the migrations just run and update the application automatically.

    Check out this post from AppHarbor. http://blog.appharbor.com/2012/04/24/automatic-migrations-with-entity-framework-4-3

    The gist is basically you want to enable auto migrations then call the DatabaseInitializer from your code, either from the OnModelCreating method or from your Global.asax.

提交回复
热议问题