Connection string for EDMX

connection-string edmx entity-framework

Question

Thus, the plot goes as follows.

A project of mine named PA.DLL has an entity model (edmx) file.

I copied the connection string that was generated (automatically) while generating the edmx file into the main app app.config of another project that I'm linking to the PA.DLL.

But when I load and execute these 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.

Anyone has any insight into the root of this error?

My connection string is set up as follows:

<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" />

Thanks

1
7
2/11/2010 2:24:06 PM

Accepted Answer

The connection string may be added to the project's configuration file that uses your DLL as a solution.
The connection string may also be supplied as code (use the parameterized constructor of PAEntities).

3
2/11/2010 2:29:30 PM

Popular Answer

Right-click the Entity Data Model file (.edmx) in the Solution Explorer and choose "Open with." You may choose an application in a dialog box to open the file. Double-click or choose "XML (text) Editor."

You are now seeing the EDM file's XML version, where you may quickly change the name of the entity container.

Make sure the 'DefaultContainerName' matches the name on section 'EntityContainer' in that XML file if you modified the connectionstring in the webconfig file.

Normally, when you change the defaultContainerName in a *.Designer.cs file, the XML file is not updated. It must thus be done by hand.



Related Questions





Related

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