Introduction
In this article, I am going to introduce a few important components of the Entity Framework Core 6.0. This article can be used by beginners, intermediates, and professionals.
We will cover
- What is Entity Framework Core?
- Domain Classes
- Types of Entity Framework Core?
- Code First Approach
- Database Approach
- EF Core Data Provider
Prerequisites
- Basic understanding of ORM (Object Relational Mapper)
What is Entity Framework Core?
Entity framework core is completely rewritten modern Object Relational Mapper (ORM) for .Net - Data Access Platform.
EF Core 6.0 is the latest version. Next Entity Framework Core version EF Core 7.0 will be released on Nov-2022.
EF core is Microsoft's official Data access platform.
Let’s see the below diagram,
As per the above images, we can say the definition would be,
“EF core is Lightweight, Extensible, Cross Platform and Opensource ORM framework introduced by Microsoft.”
The first concept would be “Domain Classes”
Domain Classes
In our application, we usually write classes like Employee, Customer, Member, and Courses for CRUD operations. These classes are called Domain Classes.
Without ORM, we will need to write a lot of code to implement the CRUD operations or map data after received from the Database.
In the EF Core, Domain classes can be used in Code First Approach and DB First Approach. Db First Approach has limited access to EF Core.
Type of Entity Framework Core
EF Core has two types of approaches,
1. Code First Approach
Code First Approach works based on Domain Driven Design.
In Code First approach,
- Create Domain Classes.
- Create DB Context class derived from EF Core Db context classes.
- EF Core creates Db and Tables using a default configuration.
- You can change the EF Core default configuration. We will see this in upcoming articles.
2. Database First Approach
The database approach will help us to create Domain classes and DB Context classes from an existing database using EF Core. It means, if you have an existing Database then we should use this approach to work with ORM.
What you will do if you have a different type of relation or non-relation database?
The answer is EF Core Database Provider.
EF Core Database Provider
EF Core provided a wide range of libraries to support various relational or non-relation databases. These libraries are available in form of Nuget packages. We need to download and install the NuGet package as per your database.
Please see the below link to get a list of EF Core Data Providers,
https://learn.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli
EF Core provider sits in between EF Core and Databases.
Let’s see the below diagram,
This article gives you overview of the important components of the Entity Framework Core. We will have more discussions in the upcoming articles.
Hope you enjoyed it.