Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
706 views
in Technique[技术] by (71.8m points)

entity framework - SQL Azure EF Database First Connection String in Azure Management Portal

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.

enter image description here

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...