What is Edmx

.edmx is basically an XML file which is generated when we added Entity Framework model. It is Entity Data Model Xml which contains designer (Model) and code file(.cs).

As you can see in following image the .edmx file in solution explorer

edmx file in ef

		Figure 1

As you can see that it’s showing .edmx file including cs file. By default when we click on .edmx file it will show the designer view

add edmx in ef

		Figure 2


When we click on .cs file which is techaltum.designer.cs it will show the code for this designer

edmx designer

		Figure 3

As my database name is techaltum_ef so it has created a namespace with same name including suffix Model

As you can see that in this namespace its showing two regions – one is context and second is entities.

designer code file

		Figure 4

In context region we will find the class name techaltum_efEntities. As we know that techaltum_ef is my database which I am using for this example. So EF designer simply create partial class using my database name and include Entities suffix with it.

You can also see that it inherits the class ObjectContext. ObjectContext is the class which is responsible to manage all CRUD functionalities for us. This class is found in System.Data.Entity namespace.

As we know that Entity Framework is ORM which provides inbuilt functionality for our CRUD application. So we are able to use that functionality using this Object Context Class.

Now expand the Entities region and you will find following data


		Figure 5

In entities region you will find your classes which generated for your table. As we added student table so student class has been created. This class also contains properties according the table column.

.Edmx file in XML Editor

As you can see that when we click on .edmx file we get our designer. We can also open this .edmx in XML Mode. But before moving this XML file I want to explain three major Schema of EDM which described in this XML file.

Three Major schema of EDM

SSDL (Storage Schema Definition Language)

It stores the schema of database which we created

CSDL (Conceptual Schema Definition Language)

It stores the schema of cs file which generated for each table of database. This files defines the properties created for that table and all the relationship.

ML (Mapping Language) or C-S M Mapping

It stores the mapping of SSDL and CSDL.

Now right click on .edmx file and open with it with XML Editor

schema of edmx

		Figure 6

Now open with it using XML(Text) Editor and you will get XML file in which you will find the all three section which we discussed.


In the starting you will find SSDL region

SSDL Schema

		Figure 7


Now move to the CSDL

CSDL Schema

		Figure 8

As you can see in CSDL it will simply generated the cs file for database table. As we use int data type in database which is declared as Int32 in c sharp. Similarly all the datataype which declared as varchar do not support Unicode character so in .cs file it’s simply showing Unicode as false.

C-S Mapping Layer

This is the layer which maps the CSDL to SSDL

C-S Mapping Layer

		Figure 9

In my next article we will start how to insert data using EF.