8
votes

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

2

2 Answers

4
votes

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

-1
votes

Your missing the Provider Name on your Web.Config file. There are three attributes on your ConnectionStrings Add Element, Name, ConnectionString and ProviderName. Your are missing the ProviderName attribute on the Add Element. I spread out the attributes to show them clearly, Just add providerName="System.Data.EntityClient" after your connectionString attribute and you should be good to go !

 <connectionStrings>
        <add 

       name="XXXXXXContainer" 

       connectionString="metadata=res://*/XXXXXX.csdl|res://*/XXXXXX.ssdl|res://*/XXXXXX.msl;
       provider=System.Data.SqlClient;
       provider connection string=&quot;
       data source=chibitestdbserver.database.windows.net;
       initial catalog=XXXXXX;
       persist security info=True;
       user id=chibionos;
       password=XXXXXXXX;
       MultipleActiveResultSets=True;
       App=EntityFramework&quot;" 

      providerName="System.Data.EntityClient" />
      </connectionStrings>