简体   繁体   English

部署ASP.Net MVC 5网站后应用更改

[英]Apply changes after deploying an ASP.Net MVC 5 website

I'm currently developing an ASP.Net MVC 5. The problem is, I have always coded the websites and handed them over to other people who managed the deployment and maintenance. 我目前正在开发ASP.Net MVC5。问题是,我总是对网站进行编码,然后将其移交给管理部署和维护的其他人员。 I have never been on the other side of the production and now I have to be. 我从来没有去过生产的另一边,现在我必须去了。 I have read some articles for ASP.Net MVC 3 but since I am creating this project with MVC 5, I was wondering what I should do in situations where the models need some changes. 我已经阅读了一些有关ASP.Net MVC 3的文章,但是由于我是使用MVC 5创建该项目的,所以我想知道在模型需要进行一些更改的情况下应该怎么做。 For instance: 例如:

  • I rename field or column 我重命名字段或列
  • Add another field to the model with acceptable default values (maybe even null) 使用可接受的默认值(甚至为null)向模型添加另一个字段
  • Remove a field 移除栏位
  • ... ...

You should be able to generate the script needed to update your database. 您应该能够生成更新数据库所需的脚本。 See this post for more information. 有关更多信息,请参见此帖子。 Basically it says: 基本上说:

Run the Update-Database command but this time specify the –Script flag so that changes are written to a script rather than applied. 运行Update-Database命令,但这一次指定–Script标志,以便将更改写入脚本而不是应用。

Open your package manager console (Tools > Library Package Manager > Package Manager Console), target your migrations project, and run "Update-Database -Script". 打开软件包管理器控制台(工具>库软件包管理器>软件包管理器控制台),定位您的迁移项目,然后运行“ Update-Database -Script”。

Then take the script and run it against your production / staging / testing / whatever environment. 然后使用脚本并针对您的生产/登台/测试/任何环境运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM