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?
2
Answers
You only need:
(It depends on .Relational)
If you need to run EF Core commands in VS Package Manger console install:
If you want the dotnet CLI EF Core tools run:
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.
(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)