Azure中的EF6连接字符串

编程入门 行业动态 更新时间:2024-10-28 06:33:26
本文介绍了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,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,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连接字符串

本文发布于:2023-10-28 13:09:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536723.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   Azure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!