views:

259

answers:

2

Hi, I am using the EntityFramework POCO adapter and since there are limitations to what microsoft gives access to with regards to the meta data, i am manually extracting the information i need out of the xml. The only problem is i want to get the ssdl, msl, csdl file names to load without having to directly check for the connection string node in app.config. In short where in the ObjectContext/EntityConnection can i get access to these file names? Worst case scenario i need to get the connection name from the EntityConnection object then load this from app.config and parse the string itself and extract the filenames myself. (But i obviously don't want to do that). Thanks

A: 

I can think of two ways to use reflection here:

  1. Dig into the EntityConnection. The connection string should be in there somewhere as a private variable.

  2. The EDM metadata files are embedded in the assembly as resources by default. You should be able to reflect the assembly that contains the EDM and pull the files out directly. Use Reflector on your assembly that contains your EDM and you should see the embedded msl, ssdl, an csdl.

I think option 2 is more robust overall.

Dave Swersky
A: 

Have you looked at the ObjectContext.MetadataWorkspace? It's not the easiest library to work with, but I was able to get all of the information that I needed.

Julia Lerman has a good chapter on the subject in her EF book.

TGnat
Yeah thats the first place I looked. Nothing looks to be exposed there.
What are you trying to get out of the raw xml files that you cannot get out of the MetadataWorkspace?
TGnat