Conceptual model, entity, context ….in Entity framework. Confused??
Say No to confusion now, since I have made this blog post to throw a perfect illusion of how all these things relate to each other.

Let’s begin…

I begin with simple language to explain and then give a formal definitions to the concepts. For short, think that we started a Mobile phone dealership. Our company requires  a software that could store the different Mobile Phone details.

Most often if we follow Object oriented paradigm then we think of representing Mobile as a class with its state information showcased as Properties of class. This is called Conceptual Model or Entity.A class that we create, resembles the physical table in database. It is used  as a means to access the physical table records via objects. The state information of the class represents the  columns in a table.
Public Class Mobile{
float dimension,weight;
String ScreenType,BodyType;
decimal price;
}

The Mobile class above represents the conceptual model and Mobile is called as entity.

What if we want to persists Mobile Phones information into database? Here we start to think in terms of relational model. We create a Table, Mobile with Columns  pertaining  to the state information of the Mobile class.

This is referred to as store model. The data model, or store model, Which is the relational model of the database underlying the EF data access layer.

This slideshow requires JavaScript.

Now that we have raw stuff with us, in order to be able to retrieve data from database version of Mobile and perform CRUD operations with  mobile conceptual model, we need a certain sort of linking between the two versions. There may be times that we need information from another store or conceptual model while retrieving, inserting or updating etc.

Like for our example of Mobiles we need the network standard features the mobile support then we take consideration of the Network standard feature models into action while doing query operations on Mobile entity.

This is the work of Context. Context provides data access logic and  act as link between conceptual model and store model. Context also helps in providing additional entities that can be part in queries.

It’s really pretty easy, isn’t It? 

 

Advertisements