Using Entity Framework Core with ASP.NET Core
Entity Framework Core is a natural way to get real data into a website. In Chapter 14, Practical Applications of C# and .NET, you created two class libraries: one for the entity models and one for the Northwind database context.
Configure Entity Framework Core as a service
Functionality like Entity Framework Core database contexts that are needed by ASP.NET Core must be registered as a service during website startup.
- In the
NorthwindWeb
project, modifyNorthwindWeb.csproj
to add a reference to theNorthwindContextLib
project, as shown highlighted in the following markup:<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp3.0</TargetFramework> </PropertyGroup> <ItemGroup> <ProjectReference Include= "..\NorthwindContextLib\NorthwindContextLib.csproj" /> </ItemGroup> </Project>
- Navigate to Terminal...