.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
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
When we click on .cs file which is techaltum.designer.cs it will show the code for this designer
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.
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
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.
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.
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
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
Now move to the CSDL
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
In my next article we will start how to insert data using EF.