Entity Framework is an open source object relational model framework for the applications built on .NET. It facilitates the developers to work with data without looking into underlying database tables and columns where the data is stored. With Entity Framework in place, developers can now create and maintain data-oriented applications with less code when compared to applications running on traditional ADO.NET code.
Before the Entity Framework came along, developers had to write ADO.NET code or Enterprise Data Access Block to perform data transitions (CRUD operations) with the respective databases. Often, this process involved opening a connection with the database, getting the data or submitting the data to the database, converting data into .NET object or a .NET object to the dataset. This was a time consuming and error prone process, so Microsoft came up with a framework called the “Entity Framework” which automates all database related activities within the application.
Using the Entity Framework within your application
The following figure illustrates where the entity framework fits into your application.
Different Types of Approaches with Entity Framework
There are three types of approaches you can use while developing your application using Entity Framework:
A little about EF Core
EF Core is a new version and advanced when compared to Entity Framework 6, but this cannot be considered as Entity Framework 7. It is rich in features and yet very simple (meaning simpler than current entity framework versions). It is the extensible and cross platform version of the entity framework, which works well with relational and non-relational databases. Further, it can be used with full Dot Net framework and it also has the ability to go with dot net core and cross platform. EF core uses principle called “pay per play”, meaning one should not pay for complex feature which he/she not using it. As EF6 is very complex, in terms of mappings, it’s very difficult to add features on top of it. EF6 consumes more time in warm up (meaning time consumed in creating the model).
In this approach, we generate the context and entities for the existing database using EDM wizard integrated in Visual Studio or executing EF commands.
EF 6 supports the database-first approach extensively. EF Core includes limited support for this approach.
This approach can be useful when we don’t have existing database for our application. Here we first create domain classes and context classes, later we create database from these classes. Developers who follow Domain Driven Design usually prefer this approach much.
In this approach, we create entities, relationships, and inheritance hierarchies directly on the visual designer integrated in Visual Studio and then generate entities, the context class, and the database script from your visual model.
EF 6 has limited support for this approach & EF core will not support this approach type.
Exploring new technical stuff and trying to incorporate them in my work domain wherever possible. - That is me. A "Performace Guru" who loves to optimize modules for the best outcomes. Movies and infotainment channels to relax and travelling with family.