Introduction
In this article, we will discuss how to install and set up Entity Framework Core in the .Net core application.
Before you start on this I strongly recommend reading “Introduction to Entity Framework Core 6.0” first and then coming back.
We will cover,
- Setup Entity Framework Core in .Net Core
Prerequisites
- Visual Studio 2022 or higher
- Basic knowledge of Asp.net Core will help.
Setup Entity Framework Core in .Net Core
Let’s create an ASP.net Core application first,
Step 1: Create Asp.Net Project
![Installing Entity Framework Core]()
Step 2: Install Nuget Packages for Entity Framework Core
Based on the database which needs to be used, respective NuGet packages needs to be installed. You can find the list of all NuGet packages based on DB in the below link,
https://learn.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli
Let's Install Nuget Package for SQL Server,
![Installing Entity Framework Core]()
Click on Install Button.
It will show and install all dependent packages as per the below image.
![Installing Entity Framework Core]()
Click on OK Button.
Please note that Entity Framework needs to have three main packages,
- Microsoft.EntityFrameworkCore. SqlServer – This is DB specific package. In this case, this package has all the required details for SQL Server DB.
- Microsoft.EntityFrameworkCore.Relational – Common Relational functionality.
- Microsoft.EntityFrameworkCore – Contain common functionality of Entity Framework Core.
If we will install “Microsoft.EntityFrameworkCore.SqlServer”, it will automatically install dependent packages like “Microsoft.EntityFrameworkCore.Relational” and “Microsoft.EntityFramworkCore”.
But if you install “Microsoft.EntityFramworkCore” first, then you need to install “Microsoft.EntityFrameworkCore.Relational” and “Microsoft.EntityFrameworkCore.SqlServer” NuGet packages manually.
Let’s see the below images for more information,
![Installing Entity Framework Core]()
Now I will show you dependencies in the Project,
![Installing Entity Framework Core]()
Now .Net core application is ready to work with EFCore. In the next article, we will create sample EntityFrameworkCore Application.
That’s all for this article. Hope you enjoyed and find it useful.