与多个Web配置变换实体框架迁移 [英] Entity Framework Migrations with Multiple Web Config Transforms

查看:169
本文介绍了与多个Web配置变换实体框架迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用实体框架与5启用迁移创建在Visual Studio 2010的ASP.NET MVC 4项目。我有不同的环境(调试,分期,发布),将指定根据环境不同的数据库是connectionStrings多个Web配置文件。如何处理使用更新,数据库命令从软件包管理器控制台与多配置文件迁移?每次我运行此命令,则默认为主体的Web.config连接字符串。感谢提前任何帮助。

I have created an ASP.NET MVC 4 project in Visual Studio 2010 using Entity Framework 5 with migrations enabled. I have multiple web config files for different environments (Debug, Staging, Release) which will specify different database connectionStrings depending on the environment. How do I handle migrations using the Update-Database command from the Package Manager Console with the multiple config files? Each time I run this command, it defaults to the main Web.config connection string. Thanks for any help in advance.

推荐答案

为了试图让事情尽可能的简单,我工作围绕在我的远程升级和生产服务器运行的迁移的方式,是运行以下命令从包控制台(数据源和用户名/密码将取决于哪个服务器我想跑对迁移更改):

In order to try and keep things as simple as possible, the way I worked around running migrations on my remote staging and production servers, is to run the following command from the package console (data source and user/pass would change depending on which server I wanted to run the migrations against):

Update-Database -Verbose -ConnectionString "Data Source=ServerName;Initial Catalog=db;User Id=user;Password=pass;" -ConnectionProviderName "System.Data.SqlClient"

本已的情况下,其他人正在寻找迄今为我工作。感谢大家的意见。

This has worked for me so far in case anyone else is looking. Thanks everyone for the comments.

这篇关于与多个Web配置变换实体框架迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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