在 Windows Azure(预览版)管理门户中,您可以更改网站的配置选项(请参阅 http://www.windowsazure.com/en-us/manage/services/web-sites/how-to-configure-websites/#howtochangeconfig)。
我当前通过 Web.Release.Config 设置 ADO.NET Entity Framework 连接的连接字符串,但我想通过管理门户设置它,但无论我使用什么,我总是会遇到以下错误:
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
它确实适用于常规连接字符串,即没有定义元数据和映射信息(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 连接的 key 。我们将其称为 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 中的 working 值复制的,带有“”替换为“.
我尝试过其他变体:使用 "未受影响,在末尾附加了元数据,但无济于事。我已在第二个网站上重现了该问题。
最佳答案
我的问题的解决方案是从实体的“SQL Azure/SQL Server/MySQL/Custom”选择器中选择“自定义”而不是“SQL Azure”框架连接字符串,即使数据库确实在 SQL Azure 上运行。
[编辑]来自下面 @matthew-steeples 的热门评论:
I would add to this for anyone else having the same issue is that sometimes the config file will have
"
instead of"
, and the Azure Websites needs those to be changed to"
关于entity-framework - 如何通过 Windows Azure(预览版)管理门户设置 ADO.NET Entity Framework 连接字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14459748/