Entity Framework - CSDL, SSDL, and MSL files
Asked Answered
C

2

17

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?

Clow answered 11/5, 2012 at 14:17 Comment(0)
T
12

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.

Tully answered 11/5, 2012 at 14:21 Comment(1)
but how com on the DDL generation process there is a step called CsdlToSsdlAndMslActivity and on its description it says that it "reads the CSDL file and generates the SSDL and the MSL file that connect the two." how can these files be generated if they already exist?Clow
F
20

If you are interested in seeing CSDL, SSDL and MSL files then build your project once which contains the EDMX files. Now, click on Show All Files button (pointed by red arrow in the screenshot) after clicking your project node in the solution explorer.

enter image description here

The directory structure says it as obj\x86\Debug\edmxResourcesToEmbed. All the Entity Framework (EF) 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 can see two sets of each file type e.g. there are two *.csdl files. Hope this view helps someone.

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

Fane answered 25/12, 2016 at 5:28 Comment(0)
T
12

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.

Tully answered 11/5, 2012 at 14:21 Comment(1)
but how com on the DDL generation process there is a step called CsdlToSsdlAndMslActivity and on its description it says that it "reads the CSDL file and generates the SSDL and the MSL file that connect the two." how can these files be generated if they already exist?Clow

© 2022 - 2024 — McMap. All rights reserved.