Fra*_*len 27 deployment entity-framework connection-string azure azure-web-sites
在Windows Azure(预览)管理门户中,您可以更改网站的配置选项(请参阅http://www.windowsazure.com/en-us/manage/services/web-sites/how-to-configure-websites/ #howtochangeconfig).
我目前通过Web.Release.Config为我的ADO.NET实体框架连接设置连接字符串,但我想通过管理门户设置它,但无论我使用什么,我总是最终得到以下错误:
指定的命名连接在配置中找不到,不打算与EntityClient提供程序一起使用,或者无效.
它适用于常规连接字符串,即没有定义元数据和映射信息的元数据键(csdl,ssdl,msl).
这是我做的:
在"连接字符串"下,我有一个名为"ApplicationServices"的键,如下所示:
Server = tcp:xxxxx.database.windows.net,1433; Database = xxxxx; User ID = xxxxx @ xxxxx; Password = xxxxx; Trusted_Connection = False; Encrypt = True; Connection Timeout = 30;
这个工作.
我有另一个用于Entity Framework连接的密钥.我们称之为一个FooBarContext.它看起来像这样:
metadata = res:// /Models.FooBarContext.csdl|res:// /Models.FooBarContext.ssdl|res://*/Models.FooBarContext.msl;provider=System.Data.SqlClient;provider connection string ="Server = tcp:fooserver.database.windows.net,1433; Database = foobar; User ID = myname @ fooserver; Password = xxxxxxxxxx; Trusted_Connection = False; Encrypt = True; Connection Timeout = 30;"
这个导致上述错误.它是从Web.Release.Config中的工作值复制的,带有" 取而代之的是".
我尝试了其他变体:" 未触及,最后添加了元数据,但无济于事.我已经通过第二个网站重现了这个问题.
Fra*_*len 47
我的问题的解决方案是从Entity Framework连接字符串的"SQL Azure/SQL Server/MySQL/Custom"选择器中选择"Custom"而不是"SQL Azure",即使数据库确实在SQL Azure上运行.
Kbd*_*s07 12
更换
"
Run Code Online (Sandbox Code Playgroud)
同
"
Run Code Online (Sandbox Code Playgroud)
在连接字符串中.
我不仅必须使用双引号(或单引号)代替"(并为类型选择自定义),而且我还必须确保我的转换配置中有一个虚拟值。我正在替换整个 connectionStrings 节点,但决定保留它并添加以下内容:
<add xdt:Transform="Replace" xdt:Locator="Match(name)" name="FooBarEntities" connectionString="temp" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)
没有这个,我收到以下错误:
The connection string 'FooBarEntities' in the application's configuration file does not contain the required providerName attribute.
| 归档时间: |
|
| 查看次数: |
15619 次 |
| 最近记录: |