您的位置:首页 > 其它

在Azure Website 中配置 Entity Framework Connection String

2015-01-19 16:56 507 查看
作为一个完整的PaaS, Windows Azure Website 还是做的非常棒的,无论是增量更新还是远程调试,都给工作带来了巨大的方便。不过最近在 Azure Website 上配置 Entity Framework Connection String 的时候却遇到了一些问题。

我在 Azure 中建了两个 Web Sites, 一个作为生产环境(使用生产环境数据库),一个作为测试环境(使用测试环境数据库)。数据库连接使用Entity Framework。为了不在Web.config 中维护 生产和测试 两套 connection string,我打算将 connection string 配置在Azure Website 的Configure里 (Azure Website 的Configure里的 connection string 会覆盖Web.config 中同名的
connection string)。





我将Web.config 中的 connection string 直接拷贝到 Azure Website 的configure 里面。结果发现如下错误:
"Keyword not supported: 'metadata'."

这个错误的原因是connection string 的类型设置成了 “SQL Database”。 将其改为"Custom"后(如下图所示),错误解决。



继续运行,又发现如下错误。
"Keyword not supported: 'data source'."
这是因为 Web.config 中将 Entity Framework 的connection String里的 引号 转义为""", 在Azure Website configure 中需要将引号转义回来。将connection string 中的 """ 还原为 引号,问题解决。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: