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

前端 未结 7 768
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:17

    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());            
        }
    

提交回复
热议问题