如何通过 Windows Azure(预览版)管理门户设置 ADO.NET 实体框架连接字符串? [英] How do I set an ADO.NET Entity Framework connection string via the Windows Azure (Preview) Management Portal?

查看:13
本文介绍了如何通过 Windows Azure(预览版)管理门户设置 ADO.NET 实体框架连接字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows Azure(预览版)管理门户中,您可以更改网站的配置选项(请参阅 http://www.windowsazure.com/en-us/manage/services/web-sites/how-to-configure-websites/#howtochangeconfig).

In the Windows Azure (Preview) Management Portal you can change the configuration options for web sites (see http://www.windowsazure.com/en-us/manage/services/web-sites/how-to-configure-websites/#howtochangeconfig).

我目前通过 Web.Release.Config 为我的 ADO.NET Entity Framework 连接设置连接字符串,但我想通过管理门户设置它,但无论我使用什么,我总是以以下错误告终:

I currently set the connection string for my ADO.NET Entity Framework connection via Web.Release.Config, but I want to set it via the Management Portal, but no matter what I use, I always end up with the following error:

指定的命名连接在配置,不打算与 EntityClient 提供程序一起使用,或无效.

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)的元数据键.

It does work for regular connection strings, ie without the metadata key defining metadata and mapping information (csdl, ssdl, msl).

这就是我所做的:

我去https://manage.windowsazure.com/#Workspaces/WebsiteExtension/Website/[MY-STAGING-SITE-NAME]/configure

在连接字符串"下,我有一个名为ApplicationServices"的键,如下所示:

Under "connection strings" I have a key named "ApplicationServices" that looks like this:

Server=tcp:xxxxx.database.windows.net,1433;Database=xxxxx;UserID=xxxxx@xxxxx;密码=xxxxx;Trusted_Connection=False;Encrypt=True;Connection超时=30;

Server=tcp:xxxxx.database.windows.net,1433;Database=xxxxx;User ID=xxxxx@xxxxx;Password=xxxxx;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;

这个有效.

我有另一个用于实体框架连接的密钥.让我们称其为 FooBarContext.它看起来像这样:

I have another key for the Entity Framework connection. Let's call that one FooBarContext. It looks like this:

metadata=res:///Models.FooBarContext.csdl|res:///Models.FooBarContext.ssdl|res://*/Models.FooBarContext.msl;provider=System.Data.SqlClient;提供者联系string="Server=tcp:fooserver.database.windows.net,1433;Database=foobar;UserID=myname@fooserver;Password=xxxxxxxxxx;Trusted_Connection=False;Encrypt=True;Connection超时=30;"

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 值复制而来的,带有 "替换为.

This one causes the error described above. It is copied from the working value in Web.Release.Config, with the " replaced by a ".

我尝试了其他变体:使用 "未触及,在末尾附加元数据,但无济于事.我已经在第二个网站上重现了这个问题.

I have tried other variations: with the " untouched, with metadata appended at the end, but to no avail. I have reproduced the problem with a second website.

推荐答案

我的问题的解决方案是从"SQL Azure/SQL Server/MySQL/实体框架连接字符串的选择器,即使数据库确实在 SQL Azure 上运行.

The solution for my problem was selecting "Custom" instead of "SQL Azure" from the "SQL Azure / SQL Server / MySQL / Custom" selector for the Entity Framework connection string, even though the database does run on SQL Azure.

来自下面@matthew-steeples 的流行评论:

From a popular comment by @matthew-steeples below:

我想为其他有同样问题的人补充一点有时配置文件会有 " 而不是 ",并且 Azure网站需要将那些更改为 "

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 "

这篇关于如何通过 Windows Azure(预览版)管理门户设置 ADO.NET 实体框架连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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