How to specify metadata location in connection string when using edmx file

I have a web project with a data model defined in an edmx file. The connection string starts as follows:

metadata = Res: // * /;

This has been working fine for a while. But someone else working on the project created a DLL that also uses the entity infrastructure and adds it to the bin folder. Now, when I try to create my connection, a metadata loading error occurs.

Besides completely changing how one or both of us do something, I wonder if the problem can be fixed if my connection string can be changed to look for the metadata defined in my edmx file. The problem is that for life, I cannot find the correct syntax for this. Metadata is built into the output assembly, so there are no physical metadata files. How to accurately indicate the location of metadata in a connection string?

+7
entity-framework
source share
1 answer

Yes, I have seen this problem before. And it was a matter of time before someone asked this question.

Basically res://*/ loads all the metadata in all assemblies, so if there are multiple sets of metadata, EF gets confused.

Thus, using res://*/ by default, since EF in WebApplications is a mistake, unfortunately, this is one that we did not have time to solve.

The workaround is to more accurately define the connection string like this: Res: ///App_Code.Northwind.csdl | Res: ///App_Code.Northwind.ssdl | Res: //*/App_Code.Northwind.msl;

Where App_Code is the App_Code folder (assuming your model is in your web project) and Northwind is the name of your EDMX. If you are having trouble getting the names to use, look at the resource names in your assembly using something like Reflector.

Doing this tells EF which CSDL, SSDL, and MSL to load from the downloaded assemblies and should solve your problem.

Hope this helps

Alex

+7
source share

All Articles