Creating a Class Library for a Northwind Database Context
Learn about defining a database context class library in EF Core, including creating a new project, adding references, configuring database context, and adjusting the mode.
We'll cover the following
Defining a database context class library
We will now define a database context class library:
Step 1: Add a new project to the solution or workspace, as defined in the following list:
Project template:
Class Library or classlib
Project file and folder:
Northwind.Common.DataContext.Sqlite
Workspace or solution file and folder:
PracticalApps
Step 2: In Visual Studio, set the startup project for the solution to the current selection. In Visual Studio Code, select Northwind.Common.DataContext.Sqlite
as the active OmniSharp
project.
Step 3: In the Northwind.Common.DataContext.Sqlite
project, add a project reference to the Northwind.Common.EntityModels.Sqlite
project and add a package reference to the EF Core data provider for SQLite, as shown in the following markup:
Get hands-on with 1400+ tech skills courses.