Azure Azure管理门户中的SQL Azure EF数据库第一个连接字符串 [英] SQL Azure EF Database First Connection String in Azure Management Portal

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

问题描述

我有一个网站运行n Azure,它使用EF数据库第一模型。



如果我将连接字符串嵌入在web.config中,并且部署全都是玫瑰色的。

 < add name =MyEntitiesconnectionString =metadata = res://*/App_Code.Model.csdl | res ://*/App_Code.Model.ssdl | res://*/App_Code.Model.msl; provider = System.Data.SqlClient; provider connection string ='Data Source = my.database.windows.net; Initial Catalog = myTest_DB; User ID = ***; Password = ***; MultipleActiveResultSets = False'providerName =System.Data.EntityClient/> 

但是,我不想要web.config中的连接字符串,因为它包含凭据。 / p>

所以我把它移动到Azure属性中的连接字符串区域。



我遇到的第一个问题是获取元数据无效关键字错误。



我通过将类型从SQL数据库更改为Custom来解决。




I have a site running n Azure, which uses EF Database First model.

If I embed the connection string in the web.config and deploy all is rosy.

<add name="MyEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string='Data Source=my.database.windows.net;Initial Catalog=myTest_DB;User ID=***;Password=***; MultipleActiveResultSets=False'"  providerName="System.Data.EntityClient"/>

But, I don't want the connection string in the web.config because it contains credentials.

So I moved it to the connection string area in Azure Properties.

First issue I hit is getting metadata invalid keyword error.

I solved that by changing the type from SQL Database to Custom.

However, I now get this error:

The connection string 'MyEntities' in the application's configuration file does not contain the required providerName attribute."

I've trawled the web and tried many variations of the connection string but not yet found the correct one.

Note: I guess I could make this an app setting and move the initialisation of the string to code, but even if only for curiosity sake I would like to know how to do it via the portal.

解决方案

The problem is not the connection string, but the inability to specify the providerName from the portal.

Try publishing with a local or dummy connection string in place, and overwriting it as you have in the Azure Application Settings. See this answer: https://stackoverflow.com/a/18964294/94853

这篇关于Azure Azure管理门户中的SQL Azure EF数据库第一个连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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