NuGet packages distribute .NET libraries and reusable assets with dependency information. Projects declare them in the .csproj file, and .NET tooling downloads and references them during restore. section 3.2.2 section 3.5
A typical NuGet workflow is:
- Add a PackageReference to the project file, or run a command such as dotnet add package Newtonsoft.Json. section 3.5
- Run dotnet restore to download declared dependencies and reference their files locally. section 3.2.2
- Build or run the application; dotnet build restores automatically, and dotnet run restores and builds automatically. section 3.2.2
Adding an EF Core provider
An ASP.NET Core application can add SQLite support with PackageReference entries for Microsoft.EntityFrameworkCore.SQLite and Microsoft.EntityFrameworkCore.Design, both version 7.0.0. Restoring these packages prepares the application for building its EF Core data model. section 12.2.1
Listing 12.1 Installing EF Core in an ASP.NET Core application
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework> #1
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference #2
Include="Microsoft.EntityFrameworkCore.SQLite" #2
Version="7.0.0" /> #2
<PackageReference #3
Include="Microsoft.EntityFrameworkCore.Design" #3
Version="7.0.0" > #3
<IncludeAssets>runtime; build; native; contentfiles; #4
Analyzers; buildtransitive</IncludeAssets> #4
<PrivateAssets>all</PrivateAssets> #4
</PackageReference>
</ItemGroup>
Inspect a complete .csproj example showing the target framework, PackageReference entries, versions, and private build-time assets. section 12.2.1
