...
/Creating a Class Library for Entity Models Using SQL Server
Creating a Class Library for Entity Models Using SQL Server
Learn about setting up the entity model for SQL Server in Entity Framework Core, configuring the entity model, and creating a database context class library.
We'll cover the following...
Setting up entity model for SQL Server
To use SQL Server, you will not need to do anything if we already set up the Northwind database earlier. But we will now create the entity models using the dotnet-ef
tool:
Step 1: Add a new project, as defined in the following list:
Project template:
Class Library or classlib
Project file and folder:
Northwind.Common.EntityModels.SqlServer
Workspace or solution file and folder:
PracticalApps
Step 2: In the Northwind.Common.EntityModels.SqlServer
project, add package references for the SQL Server database provider and EF Core design-time support, as shown in the following markup:
<ItemGroup><PackageReferenceInclude="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" /><PackageReferenceInclude="Microsoft.EntityFrameworkCore.Design" Version="7.0.0"><PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets></PackageReference></ItemGroup>
Step 3: Delete ...