部署数据库与EF 4.1的变化 [英] Deploying database changes with EF 4.1

查看:140
本文介绍了部署数据库与EF 4.1的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有大约在4.1 EF code-第一个解决方案部署数据库更改的最佳做法?我知道MS当前不支持数据库迁移的EF 4.1,但显然人们会需要从时间做到这一点时间。

Does anyone have any best practices around deploying database changes in an EF 4.1 code-first solution? I know MS does not currently support database migrations for EF 4.1, but obviously people are going to need to do this from time to time.

感谢

推荐答案

一旦你部署的数据库到生产必须执行的增量变化。这意味着你下次部署版本之前,您必须prepare在你的dev的盒子两个数据库:

Once you deployed database to production you must do incremental changes. It means that before you deploy next version you must prepare two databases in your dev box:


  • 与目前部署在生产数据库架构的数据库 - 你应该能够从源头控制得到这个所以总是正确标注/标记您的产品发布

  • 新的DB模式的数据库

一旦你有两个数据库,你可以使用一些工具来进行不同的SQL脚本为您服务。我有两个经验:

Once you have two databases you can use some tool to make difference SQL script for you. I have experience with both:

  • Visual Studio 2010 Premium / Ultimate Database tools
  • Red Gate SQL Compare

这些工具对于SQL服务器。

These tools are for SQL server.

一旦你有区别的脚本可以测试它在你的开发框。要知道,有些更复杂的变化无法通过差异脚本来创建,并要求你创建自定义的迁移脚本,例如在临时表中存储数据的现有数据重构时真正的表。另外,如果你在新版本中使用了一些新的种子数据,你必须手动添加他们到脚本或使用数据比较工具(也由这两种产品提供的)。

Once you have difference script you can test it on your dev box. Be aware that some more complicated changes cannot be created by difference script and require you to create custom migration script for example with storing data existing data in temporary tables while refactoring real table. Also if you use some new seed data in your new version you must add them manually into script or use Data Compare tools (also offered by both products).

之后,你可以计划你的生产应用程序的中断,数据库备份并运行升级脚本。

After that you can plan outage of your production application, database backup and running upgrade script.

这篇关于部署数据库与EF 4.1的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆