'EntityFrameworkCore nuget packages confusion in Asp.net Core

I'm trying to create a web application / api using the dot net core.

for the database I choose Microsoft SqlServer, and EntityFrameworkCore as ORM

in previous versions like Asp.Net MVC 5 i used like this:

Install-Package EntityFramework

and i was able to work with Migrations, DbContexts ...

but now with dot net core I saw that I have to install multiple EntityFramework nuget packages, I saw this in multiple tutorials and also in real world.

developers installing the following packages without explaining why:

Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Design
Microsoft.EntityFrameworkCore.Relational
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.Tools

I googled it so it turns out that I need only these:

Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Sqlserver
Microsoft.EntityFrameworkCore.Tools

because the Tools package brings up the Design package from this post : Purpose of package "Microsoft.EntityFrameworkCore.Design"

the question is which packages do we need in dot net core to use entityframeworkcore in our project?



Solution 1:[1]

If you are using .net 5 you need to specify the version that the package is for.

But first you need to open the package manager console. That is from View->Other Windows->Package Manager Console. There you need to make sure that the default project is the project you want to work with. Like this

Then run these commands in the package manager console:

1.

Install-Package Microsoft.EntityFrameworkCore.Tools -Version 5.0
Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 5.0
Install-Package Microsoft.EntityFrameworkCore.SqlServer.Design

(for the SqlServer.Design you don't need to specify the version)

(if you are using .net 6 just remove the "-Version 5.0" from the commands)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1