How Do i configure Entity framework in class Library project c# entity-framework service wcf


i have created a class library project which contain the entity framework object who will be responsible for common data access layer for my multiple project.after adding the generated dll file to my domain project and using the entity object from class library project, im facing with the following issue.

No connection string named 'ABC' could be found in the application config file.

i have set the Metadata Artifact processing property of edmx to Embed in Output Assembly

App.Config markup

  <?xml version="1.0" encoding="utf-8"?>
    <!-- For more information on Entity Framework configuration, visit -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <add name="ABC" connectionString="metadata=res://*/Entity.ABC.csdl|res://*/Entity.ABC.ssdl|res://*/Entity.ABC.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\ABC.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />

And Entities code are as follow

public ABC_IntegrationEntities()
            : base("name=ABC")

one more thing i am accessing database from datadirectiory "App_Data"

i am referencing the blog from

Thanks in advance!

8/20/2014 1:42:49 PM

Accepted Answer

Based on the link you gave, probably you miss this part.

Now you can either create your own .config file in this project and add the connectionstring entry of your model or simply copy the App.config file that you created in the MyEntityModel project, in your Console App project. We will adopt the simpler way. Right click the project > Add Existing Item > Go to the MyEntityModel project and add the App.config file.


When you create a library and the library is referenced from another project, EF will read the config that is relative to start up project. You can do one of the following.

  • Copy the config from library's config (copy the file and paste it to start up project)
  • Create a new config but copy the connection string information and other EF related section
  • Add existing config by add existing item and add it as link to library's config
8/20/2014 1:46:49 PM

Popular Answer

Copy your SQL connection string from library project's config file and paste it into the main project's config file which is your startup project. Which will resolve your issue.

Also, copy DbProviderFactories from library project to the main project's config file.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow