Building EF Core Models for the Northwind Tables

Learn about creating entity classes for tables, establishing relationships between the entities, and configuring the context class.

Creating entity classes for Northwind databases tables

Let’s build models to represent two of the tables in the Northwind database. The two entity classes will refer to each other, so to avoid compiler errors, we will create the classes without any members first:

Step 1: In the WorkingWithEFCore project, add two class files named Category.cs and Product.cs.

Step 2: In Category.cs, define a class named Category, as shown in the following code:

Get hands-on with 1400+ tech skills courses.