NuGet Packages

Advanced 20 min read Lesson 6 of 6

NuGet is .NET's package manager — it lets you pull in reusable libraries instead of writing everything from scratch. You've already used it in this course for Microsoft.Data.SqlClient and Microsoft.EntityFrameworkCore.SqlServer.

Installing a package — Package Manager Console

Install-Package Newtonsoft.Json

Installing a package — .NET CLI

dotnet add package Newtonsoft.Json

Installing via the GUI

Right-click your project in Solution Explorer → Manage NuGet Packages → search by name → Install.

Packages you'll actually use across this course

Package Purpose
Microsoft.Data.SqlClientADO.NET SQL Server access
Microsoft.EntityFrameworkCore.SqlServerEF Core with SQL Server
Microsoft.EntityFrameworkCore.ToolsMigrations from Package Manager Console
xunit + xunit.runner.visualstudioUnit testing
Newtonsoft.JsonAdvanced JSON serialization
Serilog.AspNetCoreStructured logging

Where package versions live

Open your .csproj file — every installed package appears here:

<ItemGroup>
  <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
  <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" />
</ItemGroup>

Updating and removing packages

dotnet add package Microsoft.Data.SqlClient --version 5.2.2
dotnet remove package Newtonsoft.Json

A word of caution

Only install packages from trusted, well-known publishers with high download counts. A package is code that runs inside your application — treat adding one with the same care as adding a new team member.

Key Takeaway

NuGet packages save time and effort, but always verify the source before installing.

Test Your Knowledge - Take Quiz