Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF6 Connection String in Azure

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:

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.

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.

Any help would be appreciated

like image 500
user2981411 Avatar asked Jan 31 '16 23:01

user2981411


People also ask

What is connection string in Azure function?

Get connection information Sign in to the Azure portal. Select SQL Databases from the left-hand menu, and select your database on the SQL databases page. Select Connection strings under Settings and copy the complete ADO.NET connection string. For Azure SQL Managed Instance copy connection string for public endpoint.

How do I get Azure SQL database connection string?

Get ADO.NET connection information (optional - SQL Database only) 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.

How do I change my connection string in Azure?

Configure connection strings. In the Azure portal, search for and select App Services, and then select your app. In the app's left menu, select Configuration > Application settings. For ASP.NET and ASP.NET Core developers, setting connection strings in App Service are like setting them in <connectionStrings> in Web.


1 Answers

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

like image 151
crichavin Avatar answered Dec 06 '22 15:12

crichavin