Few lines about Entity Framework
The Entity Framework is an object-relational mapping framework or O/RM.For more info on O/RM refer Magic Wand: Object-relational mapping. It was released with .NET 3.5 SP1.
What we achieve with EF is the separation between the representation details like a conceptual model from the implementation details like a relational data store. EF uses mapping details to bridge the conceptual model to its data storage model. We can have a sense of independence during implementation provided by the isolation between models and layers.In this way, we can create a model of entities that hold data in an object-oriented way. This isolation helps us to model the data store in an abstract way and target potentially any data store.
What is EDMX?
EDMX is an extended version of the Entity-Relationship model where Entity data model specifies the conceptual model of the data. EDMX file can be seen as a container of Entity Data Model.
An .edmx file is an XML file that defines a model that can be used with Entity Framework. The model is made up of a conceptual model, a storage model, and the mapping between these models.
By default, an .edmx file opens with the EF Designer and it is also the recommended practice for creating and editing an .edmx file.
Steps to add edmx file.
- Open or create the project.
- Right-click on the project name and select Add-> New Item .
- Select ADO.NET Entity Data Model template.
- Entity Data Model Wizard starts.
- Either Select ‘Empty Model’ or ‘Generate from Database’ and click Finish
.edmx file encapsulates the storage model, the conceptual model, and mappings.
Conceptual Model: This model is an abstract representation for the entity types, complex types, associations, entity containers, entity sets, and association sets mapped to a relational data store. The conceptual model is defined in CSDL in the .csdl file.
Storage model: This can be defined as a relational database represented as a abstraction in conceptual model. The storage model is defined in SSDL in the .ssdl file.
Mapping : This represents a bridge between conceptual model and storage model.
Eager loading: Loading related objects along with the object requested in the query.
Explicit loading: Delay in loading related objects along with the object requested in the query till they are requested using the ‘Load’ method on a navigation property.
Lazy loading: Delay in loading related objects along with the object requested in the query till their navigation property is accessed.