8

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

user2981411
  • 859
  • 12
  • 34

2 Answers2

5

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

Community
  • 1
  • 1
crichavin
  • 4,672
  • 10
  • 50
  • 95
-2

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>
C B
  • 1,964
  • 14
  • 13
  • Thanks. I already have that. If you look at the connection string I have shown, it has the provider Name. That is what the confusion is about. The error message says give me the provider while it is already in the connection string!!! – user2981411 Feb 03 '16 at 13:11
  • could you have another attempt at answering our problem please. Thanks! – user2981411 Feb 03 '16 at 17:36