首先使用实体​​框架代码-如何为生产数据库运行Update-Database [英] Entity framework code first - how to run Update-Database for production database

查看:98
本文介绍了首先使用实体​​框架代码-如何为生产数据库运行Update-Database的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何为生产数据库运行'Update-Database'命令.

I wanting to know how to run the 'Update-Database' command for a production database.

"Update-Database"数据库在本地计算机上运行良好,但是如何使它用于生产数据?

The 'Update-Database' database works fine from my local machine, but how do I get this to work for production data?

因此,如果我对我的应用程序进行更改,然后通过Visual Studio运行发布",则对于代码方面而言,它可以很好地工作,但是如何对生产数据运行"Update-Database"命令.

So, if I make a change to my application and then run the 'publish' through visual studio this works fine for the code side of things, but how do I run the 'Update-Database' command for the production data.

希望这个问题有意义...

Hope this question makes sense...

谢谢

推荐答案

添加@David已经说过的话...

To add on what @David said already...

就我个人而言,在实时"场景中我不信任automatic updates,而且我始终更喜欢手动数据库管理(即,创建或更改Db所需的permissions存在问题-更不用说共享主机了. ),但据我所知,迁移在同步方面相当可靠(实际上,通常取消绑定"的唯一方法是删除Db并强制执行完整/新更新).

Personally, I don't trust automatic updates in 'live' scenarios, and I always prefer manual database administration (i.e. there is a problem with permissions needed to create or alter Db - not to mention shared hosting etc.) - but from what I've seen migrations are pretty solid when it comes to synchronizing (in fact, the only way to 'untie' them normally is to remove the Db and force full/fresh update).

这是我不久前发表的关于如何scriptsynchronize database / code的文章,并针对部署场景(以及出现问题时)进行了介绍.它不适用于您(但),但请记住一些注意事项.

Here is a post I made a while ago on how to script and synchronize database / code and geared towards deployment scenarios (and when problems arise). It doesn't apply to you (yet) but something to keep in mind.

MVC3和代码优先迁移-支持'blah'上下文的模型自创建数据库以来已更改"

这篇关于首先使用实体​​框架代码-如何为生产数据库运行Update-Database的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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