Entity Framework

What is Entity Framework..?

Entity Framework(EF) is an open source Object-Relational Mapping(ORM) framework for ADO.NET which was a part of .NET Framework. However since Entity Framework version 6 it is separated from .NET framework. It is an enhancement to ADO.NET that gives developers an automated mechanism for accessing & storing the data in the database.

Why Entity Framework..?

  1. Entity Framework is an ORM and ORMs are aimed to increase the developer’s productivity by reducing the redundant task of persisting the data used in the applications.
  2. Entity Framework can generate the necessary database commands for reading or writing data in the database and execute them.
  3. If you’re querying, you can express your queries against your domain objects using LINQ to entities.
  4. Entity Framework will execute the relevant query in the database and then materialize results into instances of domain objects to work within app.

Microsoft has given the below definition of Entity Framework

The Microsoft ADO.NET Entity Framework is an Object/Relational Mapping (ORM) framework that enables developers to work with relational data as domain-specific objects, eliminating the need for most of the data access plumbing code that developers usually need to write. Using the Entity Framework, developers issue queries using LINQ, then retrieve and manipulate data as strongly typed objects. The Entity Framework’s ORM implementation provides services like change tracking, identity resolution, lazy loading, and query translation so that developers can focus on their application-specific business logic rather than the data access fundamentals.

Entity framework is useful in three scenarios.

  1. If already have existing database or need to design the database ahead of other parts of the application.                                                                                                                                                           – EF creates data access classes for existing database, so that can use these classes to interact with the database instead of ADO.Net directly.
  2. If needed to focus on domain classes and then create the database from domain classes.
    – EF can create the database from domain classes, thus can focus on domain-driven design.
  3. If needed to design the database schema on the visual designer and then create the database and classes.
    – EF provides a model designer where can design a DB model and then EF creates database and classes based on the DB model.

The following figure illustrates the above scenarios.

Source: entityframeworktutorial.net
Source: entityframeworktutorial.net

Note: Entity Framework is an open source framework. So you can contribute to the Entity Framework project on codeplex.

Leave a Reply

Your email address will not be published. Required fields are marked *