I read some of the posts on this problem, and then recommended placing the code from the app.config file from my DAL into the project that loads the application. I don’t have an app.config file in my DAL and I’m not reaslly sure why or the correct syntax to build one. Help would be appreciated!
The error is being thrown when it hit the following method in my FCGuide.Designer.cs. FCGuide is the name of my edmx file. gere is the method:
public FCGuideEntities() : base("name=FCGuideEntities", "FCGuideEntities")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
The complete error is: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
I do have a connection string in my web.config.
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
<connectionStrings>
<add name="FCGuideEntities" connectionString="metadata=res://*/FCGuide.csdl|res://*/FCGuide.ssdl|res://*/FCGuide.msl;provider=System.Data.SqlClient;provider connection string="data source=.;attachdbfilename=|DataDirectory|\FCGuide.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
It sounds like you’re referencing a SQL Connection string by name that doesn’t exist.
Check the connection string in your web.config:
And make sure the code to access the connection string doesn’t have a typo.
Otherwise, you will need to add the connection string to your calling app’s web.config file.