Azure中的EF6连接字符串 [英] EF6 Connection String in Azure

查看:79
本文介绍了Azure中的EF6连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Azure上有一个网站和一个sql服务器.我们在Azure门户中包含了Entity Framework连接字符串,但是出现以下错误: 应用程序配置文件中的连接字符串'MyEntities'不包含必需的providerName属性."

We have a website and a sql server on Azure. We have included the Entity Framework connection string in the Azure Portal but we get the following error: The connection string 'MyEntities' in the application's configuration file does not contain the required providerName attribute."

看看连接字符串,它显然具有提供程序:

Looking at the connection string it clearly has the provider:

元数据= res:///MyEntities.csdl|res:///MyEntities.ssdl|res://*/MyEntities.msl;provider=System.Data.SqlClient ; provider connection string =数据源= tcp:myserver.database.windows.net,1433;初始目录= mydatabase;用户id = user @ myserver;密码= PASSWRD; MultipleActiveResultSets = True; App = EntityFramework"" providerName ="System.Data.EntityClient"

metadata=res:///MyEntities.csdl|res:///MyEntities.ssdl|res://*/MyEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:myserver.database.windows.net,1433;initial catalog=mydatabase;user id=user@myserver;password=PASSWRD;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"

那么它要什么呢?我们也用普通的引号替换了",但仍然出现此错误.

so what is it asking for ? We also replace the " with normal quotes but we still get this error.

在我们的开发中使用相同的连接字符串并连接到azure sql服务器时,一切正常,但是以某种方式放入门户网站中替换web.config中的一个的连接字符串会出现问题.

When using the same connection string in our development and connecting to the azure sql server everything works, but somehow the connection string we put in the portal that replaces the one in the web.config has problems.

任何帮助将不胜感激

推荐答案

门户不具有接受providerName属性的功能.这样,您需要将连接字符串保留在web.config中,该连接字符串指定名称和providerName,但只需为连接字符串放入一个虚拟值即可.现在,将该连接字符串值放入门户网站连接字符串中.当它运行时,它将从web.config中获取providerName,然后用您在Azure门户应用程序设置[连接字符串]中放置的连接字符串值覆盖web.config中的虚拟连接字符串.请参见 Azure中的SQL Azure EF数据库优先连接字符串管理门户

The portal doesn't have the capabilities to accept the providerName attribute. As such, you need to keep the connection string in your web.config, which specifies the name and the providerName but just put in a dummy value for the connection string. Now put that connection string value in the portal connection string. When it runs, it will pick up the providerName from the web.config, but then overwrite your dummy connection string that is in the web.config with the connection string value you put in Azure portal Application Settings [Connection Strings]. See SQL Azure EF Database First Connection String in Azure Management Portal

这篇关于Azure中的EF6连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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