In this Bog Post I’ll show how to install Entity Framework Core in a ASP.NET Core Project using VS Code on Mac, In Visual studio we can use nugget package management console but here in vs code at the time of writing this article, we don’t have that available so I’ll demonstrate this using terminal.

You can open terminal directly on vs code by typing control + ~

Now using dotnet command line interface

Type this command:

dotnet add package Microsoft.EntityFrameworkCore.SqlServer

After doing this vs code will tell you there are unresolved dependencies.

Basically when we execute dotnet add package …   it adds an entry to the .csproj file.

Here we can see this line was added

<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />

Now you can just click on the restore blue button to restore it or in Terminal type command: dotnet restore

Then we need to install entity framework tools in order to have available EF commands. Paste this block of xml on your .csproj just below the project tag.

    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Then run dotnet restore on your terminal. This is exactly as npm install in node.

After doing we should have a bunch of EF commands that are available for the dotnet cli.

If you type dotnet ef you will should see this.

You can also type for example

dotnet ef database –help

to get help on some of the commands availble.

finally type this command in terminal to install  Microsoft.EntityFrameworkCore.Design package.

dotnet add package Microsoft.EntityFrameworkCore.Design

With this we have installed EF Core on Mac. In the next Post I’ll go aver how to create and Configure a Db Context, Apply Migrations, Visualize entities on Slq Pro for MSSQL.