Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 334
Kildareflare Avatar asked Apr 11 '16 21:04

Kildareflare


People also ask

How do I get Azure DB connection string?

Navigate to the database blade in the Azure portal and, under Settings, select Connection strings. Review the complete ADO.NET connection string. Copy the ADO.NET connection string if you intend to use it.

Where is connection string in Azure portal?

You can find your storage account's connection strings in the Azure portal. Navigate to SETTINGS > Access keys in your storage account's menu blade to see connection strings for both primary and secondary access keys.

How do I connect Excel to Azure SQL Database?

To connect Excel to a database in SQL Database, open Excel and then create a new workbook or open an existing Excel workbook. In the menu bar at the top of the page, select the Data tab, select Get Data, select From Azure, and then select From Azure SQL Database.


1 Answers

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

like image 199
Loren Paulsen Avatar answered Oct 12 '22 22:10

Loren Paulsen