Connection string for EDMX

connection-string edmx entity-framework


so the story is like this.

I have a project, called PA.DLL, which have an entity model inside of it (edmx) file.

In another project which i'm referencing to the PA.DLL, i copied the connection string that was created (automatically) when creating the edmx file into the main app app.config.

however, when i load and run the following lines:

using (PAEntities analytix = new PAEntities())

i get the following error:

System.ArgumentException: The specified default EntityContainer name 'PAEntities' could not be found in the mapping and metadata information.

Does anyone has any idea what the cause for this error?

This is how my connection string is configured:

<add name="PAEntities" 
    connectionString="metadata=res://*/PAEntities.csdl|res://*/PAEntities.ssdl|res://*/PAEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=XSXSX;Initial Catalog=PA;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />


2/11/2010 2:24:06 PM

Accepted Answer

One solution is to place the connection string to the configuration file of the project consuming your DLL.
The other one is to pass the connection string in code (use the parameterized constructor of PAEntities).

2/11/2010 2:29:30 PM

Popular Answer

On the Solution Explorer, right click the Entity Data Model file (.edmx) and click 'Open with'. A dialog box will open up to choose a program for you to open the file. Select or Double click on 'XML (text) Editor'.

Now you re looking at the XML version of the EDM file where you can easily edit the 'EntityContainer' name.

If you have changed the connectionstring on the webconfig file, make sure the 'DefaultContainerName' is the name on section 'EntityContainer' in that XML file.

Usually when you update the defaultContainerName in *.Designer.cs file, it doesn't update the XML file. So you have do it manually.

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