Introduction to Entity framework

Entity framework is an Object Relational Mapping (ORM) framework. It offers developers an automated mechanism for storing and accessing the data from the database.

It was first released in 2008. Entity framework was developed by Microsoft for interacting between .NET applications and relational databases.

What is Entity Framework?

Entity Framework is an Object Relational Mapper (ORM). It is a type of tool that is used for mapping between objects in software and the columns of the relational database.

Entity Framework is an open-source ORM framework; it is basically designed for ADO.NET. ADO.NET is part of the .NET Framework.

The main task of ORM is creating connections for the database, executing commands and taking query results. ORM automatically generates the result for application objects. ORM also track changes in object and can also undo the changes in the database as and when required.

ORM is specially designed for increasing the productivity of developers by reducing the redundancy in the task of the complete data which is used in the application.

Entity Framework can also generate database command which is used for reading and writing data into the database.

Entity Framework executes the data in the database and then combines results in domain objects which work within the application.

There are many ORMs in the market like NHibernate and LLBLGen Pro.

ORMs can map the domain directly to the database schema. Entity Framework has more small mapping layers. Mapping can be done into a single entity to multiple database tables or multiple entities to a single table.

History and Versions of Entity Framework

  • In 2008, the first version of Entity Framework (EFv1) was released. It includes .NET Framework 3.5 Service Pack 1 and Visual Studio 2008 Service Pack 1.
  • In 2010, the second version of Entity Framework was released named Entity Framework 4.0 (EFv4).
  • In 2011, the third version of Entity Framework was released named Entity Framework 4.1, with the support of Code First.
  • In July 2011, an updated version of 4.1 was released which was named Entity Framework 4.1 Update 1. In the new version, it can fix the bug and many new support types.
  • In 2012, version 4.3.1 was released. In this version, the main operation was that it has support for migration.
  • In August 2012, Version 5.0.0 was released. This version was available for .Net framework 4.
  • In 2013, Version 6.0 was released. In this version, it has an open source project licensed under Apache License v2.
  • In 2016, Entity Framework Core 1.0 was released. It was originally named Entity Framework 7
  • In 2017, Entity Framework Core 2.0 was released.

Conceptual Model

The biggest advantage of Entity Framework is that it let the developers focus on the business domain.
In Entity Framework, the focal point is referred to as a conceptual model. It refers to a model of an object of your application.
The conceptual model can be aligned with the database schema. It may be different.
Visual Designer can define a conceptual model. This is used to generate classes that can be used in the application.
Defining classes and using features of Entity Framework called Code First.
Entity Framework is used to move a conceptual model to the database.

Features of Entity Framework

  1. Entity Framework is a Microsoft tool.
  2. Entity Framework is an Open Source product.
  3. Entity Framework is not dependent on the .NET release cycle.
  4. Any relational database can work with a valid Entity Framework provider.
  5. In Entity Framework, SQL command is generated from LINQ to Entities.
  6. Parameterized queries can be created.
  7. Tracks can be changed to in-memory objects.
  8. It allows generation of the insert, update and delete commands.
  9. It has Stored Procedure Support.

The architecture of Entity Framework

The architecture of the Entity Framework consists of the following things:

Data Providers

The data provider is source specific. The ADO.NET interface is connected to the database when programming is done against the conceptual schema. It can translate SQL language such as LINQ to native SQL and execute it to a specific DBMS system.

Entity Client

Entity client provides developer to work in the form of rows and columns using SQL queries without generating classes to represent a conceptual schema. These layers are called as Entity Data Model. The entire database schema in XML format is contained in Storage Layer. Entity Layer is an XML file that defines the entities and their relationships. The Mapping layer is an XML file which is used for mapping the entities and relationships that is defined at the conceptual layer.

Object Service

In this layer, the object context represents a session of interaction between the applications and the data source. Object Context can perform different operations like add, delete and can save the changes back to the database with the help of queries. OMR layer represents the data result. Object service helps the developer to use rich ORM features like primary key mapping, change tracking, etc.

Advantages of Entity Framework

  1. Entity Framework provides auto-generated code.
  2. Entity Framework reduces development time.
  3. Entity Framework reduces development cost.
  4. Entity Framework allows developers to visually design models and mapping of the database.
  5. Entity Framework provides unique syntax for object queries.
  6. In Entity Framework, it is easy to map business objects.

 Disadvantages of Entity Framework

  1. Very slow loading process.
  2. The syntax is complicated.
  3. The logical schema cannot understand business entities and their relationships.
  4. Data is handled in a non-traditional way.
  5. If database schema is changed, it does not work.

Reference:
https://www.entityframeworktutorial.net/basics/how-entity-framework-works.aspx
https://www.tutorialspoint.com/entity_framework/entity_framework_overview.htm

Pin It on Pinterest

Share This