Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework - CSDL, SSDL, and MSL files

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?

like image 840
Diego Avatar asked May 11 '12 14:05

Diego


2 Answers

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.

like image 175
RBT Avatar answered Oct 16 '22 05:10

RBT


Those files (.csdl, .ssdl, .msl) are generated at build time, and embedded as resources, into the assembly for use by the Entity Framework classes at runtime. Generating a database from a model is a different process that generates a database creation script.

like image 23
Dave Swersky Avatar answered Oct 16 '22 03:10

Dave Swersky