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..?
- 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.
- Entity Framework can generate the necessary database commands for reading or writing data in the database and execute them.
- If you’re querying, you can express your queries against your domain objects using LINQ to entities.
- 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.
- 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.
- 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.
- 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.
Note: Entity Framework is an open source framework. So you can contribute to the Entity Framework project on codeplex.