WorkFlow in Entity FrameworkHere we will learn about the basic CRUD workflow using the Entity Framework. Now we will learn about the Entity Framework workflow.
Working of Entity FrameworkHere 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. Entity Data ModelThe 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. Conceptual ModelEntity Framework builds the conceptual model for our domain classes, context class, default conventions, which is followed in our domain classes and configuration. Storage ModelEntity 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. MappingsEntity 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. QueryingEntity 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. SavingEntity 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. Next TopicDatabase-First(Schema First) Approach |