Javatpoint Logo
Javatpoint Logo

WorkFlow in Entity Framework

Here we will learn about the basic CRUD workflow using the Entity Framework.

WorkFlow in Entity Framework

Now we will learn about the Entity Framework workflow.

  1. Here, first of all, we need to define our model. Determining the model includes defining the domain classes, context class derived from DBContext, and configurations. Entity Framework will perform the CRUD operations, which is based on our model.
  2. To insert the data, we will add a domain object to a context and call the 'SaveChanges()' method. Entity Framework API will build an appropriate INSERT command and execute it to the database.
  3. To read the data, we will execute the LINQ-to-Entities Query in our preferred language (C#,VB.NET). Entity Framework API will convert this query into SQL Query for the relational database and execute it. The result will be transformed into the domain (entity) object and displayed on the UI.
  4. To edit or delete the data, update or remove the Entity objects from a context and call the 'SaveChanges()' method. Entity Framework API will build the appropriate UPDATE or DELETE command and execute it to the database.

Working of Entity Framework

Here we will see how the Entity Framework works.

Entity Framework API (EF6, EF Core) includes the ability to map the domain (entity) classes to the database schema, translate and execute the LINQ queries to SQL, track the changes occurred on the Entities during the lifetime and save the changes to the database.

WorkFlow in Entity Framework

Entity Data Model

The first task of the Entity Framework API is to build an Entity Data Model (EDM). EDM is an in-memory representation of the entire metadata: Conceptual Model Storage Model, and the mapping between them.

WorkFlow in Entity Framework

Conceptual Model

Entity Framework builds the conceptual model for our domain classes, context class, default conventions, which is followed in our domain classes and configuration.

Storage Model

Entity Framework builds the storage model for the schema of the database. In the Code-First approach, this will be analysis from the conceptual model. In the database-first approach, this will be an analysis from the targeted database.

Mappings

Entity Framework includes the information of the mapping on how the conceptual model maps to the schema of the database (Storage Model).

Entity Framework performs the CRUD operations using this EDM. It uses EDM in building the SQL queries, building the INSERT, UPDATE, and DELETE commands and transform the result of the database into entity objects.

Querying

Entity Framework API translates LINQ-to-Entities Queries to SQL queries for the relational database using EDM and also converts the results to the entity objects.

WorkFlow in Entity Framework

Saving

Entity Framework infers the INSERT, UPDATE, and DELETE commands based on the state of entities when the SaveChanges() method is called. The ChangeTrack keeps track of the states of each entity and when an action is performed.

WorkFlow in Entity Framework





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA