© Eric Vogel 2021
E. VogelBeginning Entity Framework Core 5https://doi.org/10.1007/978-1-4842-6882-7_3

3. Entities

Eric Vogel1  
(1)
Okemos, MI, USA
 

Entities are the focus of Entity Framework Core 5. An entity is an object that maps to one or more tables in a database. Entity Framework Core 5 uses a code-first approach. This means that you create your entities and Entity Framework will generate the database schema to store your entity data.

Person Entity

Our first entity is going to be a Person entity that will have an Id, first name, last name, and one-to-many addresses. The address will be its own entity. First, let’s make the Person entity without any addresses.

To get started, create an Entities folder in the Core project. Next, add a Person class ...

Get Beginning Entity Framework Core 5: From Novice to Professional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.