Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Web Sites connection string for EF not being picked up

I am deploying an ASP.NET web app to Azure Web Sites.

The site uses Entity Framework, and when I include the following in Web.config it runs fine:

<connectionStrings>
  <add name="DataContext" connectionString="metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

However, if this connection string is removed and instead specified via the Azure Management Portal, an error occurs.

Name:  DataContext
Value: metadata=res://*/Models.WpsData.csdl|res://*/Models.WpsData.ssdl|res://*/Models.WpsData.msl;provider=System.Data.SqlClient;provider connection string="data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;multipleactiveresultsets=True;application name=EntityFramework"
Type:  Custom

This results in the error: No connection string named 'DataContext' could be found in the application config file.

like image 532
James Avatar asked Sep 22 '13 18:09

James


1 Answers

See similar question here.

Try leaving the connection string in web.config with some value (either some test connection string, or some dummy value) e.g.

<connectionStrings>
  <add name="DataContext" connectionString="dummy" providerName="System.Data.EntityClient" />
</connectionStrings>
like image 156
David Ebbo Avatar answered Oct 13 '22 00:10

David Ebbo