首先部署实体框架代码 [英] Deploy Entity Framework Code First

查看:183
本文介绍了首先部署实体框架代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在开始我的项目之前我应该​​考虑一下这个问题,但是我已经使用代码优先的方法成功构建和测试了一个迷你应用程序,我已经准备好将其部署到生产Web服务器。



我已将文件夹移动到我的分段服务器,一切正常。如果有一个建议的部署策略,我只是好奇?



如果我更改了应用程序,我不想丢失所有的数据,如果应用程序重新启动



我应该从代码优先项目生成DB脚本,然后将其移动到我的服务器吗?



任何提示和指导链接都将是有用的。



谢谢。

解决方案

实际上,数据库初始化程序仅适用于开发。将这些代码部署到生产中是获得一些麻烦的最佳方法。代码优先目前没有任何数据库演进的方法,所以您必须在新版本之后手动将更改脚本构建到数据库。最简单的方法是在VS Studio 2010 Premium和Ultimate中使用数据库工具。如果您有一个具有旧架构的数据库和具有新模式的数据库,VS将为您准备更改脚本。


I guess I should have thought of this before I started my project but I have successfully built and tested a mini application using the code-first approach and I am ready to deploy it to a production web server.

I have moved the folder to my staging server and everything works well. I am just curious if there is a suggested deployment strategy?

If I make a change to the application I don't want to lose all the data if the application is restarted.

Should I just generate the DB scripts from the code-first project and then move it to my server that way?

Any tips and guide links would be useful.

Thanks.

解决方案

Actually database initializer is only for development. Deploying such code to production is the best way to get some troubles. Code-first currently doesn't have any approach for database evolution so you must manually build change scripts to your database after new version. The easiest approach is using Database tools in VS Studio 2010 Premium and Ultimate. If you will have a database with the old schema and a database with the new schema and VS will prepare change script for you.

这篇关于首先部署实体框架代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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