skip to Main Content

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


  1. 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
    
    Login or Signup to reply.
  2. 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)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search