【问题标题】:EntityFramework Migration Specify web.configEntityFramework 迁移指定 web.config
【发布时间】:2013-03-14 00:00:05
【问题描述】:

我正在使用 MV4 和 EF5。有没有办法让 EntityFramework Migration 从 web.debug.config 或 web.release.config 中提取连接字符串。

除非连接字符串在 web.config 中,否则运行 update-database 似乎会引发错误

【问题讨论】:

  • 查看System.Configuration.ConfigurationManager.ConnectionStrings

标签: asp.net-mvc entity-framework entity-framework-5


【解决方案1】:

这是因为 web.config 是应该找到连接字符串的位置。 Web.release.configWeb.debug.config 是基于当前“解决方案配置”的配置转换。详情请见this MSDN article

简短的回答是,当然连接字符串应该在 Web.config 中,因为这是它的设计目标。

您可以使用 Update-Database 上的 -ConnectionStringName 或 -ConnectionString 参数为迁移指定不同的连接。

【讨论】:

  • 这是否意味着它不能在转换配置中?
猜你喜欢
  • 1970-01-01
  • 2019-11-21
  • 2021-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多