Entity Framework - CSDL, SSDL, and MSL files

Diego picture Diego · May 11, 2012 · Viewed 22.4k times · Source

I'm just being picky but I was researching how does Entity Framework generates the DLL from an EDMX file and I saw this on msdn:

The Entity Data Model Designer (Entity Designer) stores model and mapping information in an .edmx file at design time. At build time the Entity Designer uses the information in an .edmx file to create the .csdl, .ssdl, and .msl files that are needed by the Entity Framework at runtime.

I actually found strange it saying that "at build time" the .csdl, .ssdl, and .msl are created so I decided to test. I know that the files are generated based on the TablePerTypeStrategy.xaml flow, so I removed it and tried to build my the application. It succeeded.

When I picked "generate database from model" I did get an error saying the TablePerTypeStrategy.xaml file was missing. So I got confused, clearly from this test the generation is being made when I try to generate the database, not build the application.

What am I missing here?

Answer

RBT picture RBT · Dec 25, 2016

If you are interested in seeing *.csdl, *.ssdl, *.msl files then first build your project once. Now, click on "Show All Files" button in solution explorer(shown with red arrow) after selecting your project (containing the edmx files) as shown in the snapshot below.

enter image description here

The directory structure says it as obj\x86\Debug\edmxResourcesToEmbed. All the entity framework specific xml files are created during build as they can be seen in obj folder and are embedded as resource.

I had two edmx files in my project namely EFCoding.edmx and Model1.edmx so you are seeing two respective sets of each type of file. Hope this view helps someone.

Note: All these EF meta information files can also be simply copied to project output directory (in place of embedding them) by simply tweaking a property for EF model designer as suggested here.