Defining the entities

Entities in EF Core are POCO classes, which means that you don't need to inherit from any base class to use them as your data model. Here is how the Product entity is defined:

public class Product{    // Primary key    public int ProductId { get; set; }    // Value propertis    public User Owner { get; set; }    public string Title { get; set; }    public string Description { get; set; }    // Navigation properties - represents relationships    public Category Category { get; set; }    public City City { get; set; }    public IList<ProductMedia> Media { get; set; }    public DateTime PublishDate { get; set; }}

I divided the class into three sections:

  • Primary key: Each entity must have a unique identity, called the Primary Key, which is composed from ...

Get Hands-On Full-Stack Web Development with ASP.NET Core 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.