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?
CodePudding user response:
You only need:
Microsoft.EntityFrameworkCore.Sqlserver
(It depends on .Relational)
If you need to run EF Core commands in VS Package Manger console install:
Microsoft.EntityFrameworkCore.Tools
If you want the dotnet CLI EF Core tools run:
dotnet tool install --global dotnet-ef
CodePudding user response:
If you are using .net 5 you need to specify the version that the package is for.
But first make sure that the project you want to install the packages is your StartUp Project. Then in the package manager console make sure that default project is the project you want to install the packages.
Packege Manager Console settings
Then run these commands in the package manager console:
- 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)