[英]What is the best way to run EF migration on production server?
What I have: 我有的:
What I need: 我需要的:
Notes: 笔记:
I'm running my migrations on my dev station with "dnx ef database update". 我正在使用“dnx ef database update”在我的开发站上运行迁移。 I guess I can use the webapp PS console but... doesn't seems like the proper way.
我想我可以使用webapp PS控制台,但......似乎不是正确的方法。
I know I can generate a SQL script for the migration but this seems to be too manual. 我知道我可以为迁移生成一个SQL脚本,但这似乎太手动了。
I remember that the "Publish" wizard had option "Execute EF migrations" in the past. 我记得“发布”向导过去有选项“执行EF迁移”。 Can't see it now.
现在看不到它。
It depends on who has control over the production DB (dev team or separate DBA team). 这取决于谁可以控制生产数据库(开发团队或单独的DBA团队)。
In a customer project that I worked on, each developer had their own copy of the DB, where they tested all their migrations. 在我工作的客户项目中,每个开发人员都有自己的数据库副本,他们在那里测试了所有的迁移。 Once the application code and migration code got checked in, we used TeamCity as a CI server to deploy the website, update the staging DB, and run unit tests & integration tests.
签入应用程序代码和迁移代码后,我们使用TeamCity作为CI服务器来部署网站,更新登台数据库,以及运行单元测试和集成测试。
We provided the SQL scripts (generated by EF) to the DBA team to run against the production DB. 我们将SQL脚本(由EF生成)提供给DBA团队以针对生产数据库运行。 Our dev team never touched the production DB.
我们的开发团队从未接触过生产数据库。
If you're allowed to update the production DB, you can do it yourself. 如果您被允许更新生产数据库,您可以自己完成。 But I would highly recommend inspecting and then running EF-generated scripts that you can roll back if necessary.
但我强烈建议检查然后运行EF生成的脚本,必要时可以回滚。 Also, don't forget to back up the production DB as needed.
另外,不要忘记根据需要备份生产数据库。
Since you want automation (and if you are comfortable with it), you can use your CI system to update your production DB, the way my team and I updated our staging DB. 由于您需要自动化(如果您对它感到满意),您可以使用CI系统更新您的生产数据库,这是我的团队和我更新我们的暂存数据库的方式。
Hope that helps! 希望有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.