The Entity Framework Core Model

An Entity Framework Core model is a conceptual model of an application's domain. The domain includes all topics relevant to the problem solving areas of interest to the application users. The model includes data and can also include behaviour. Typically, models for CRUD applications don't tend to incorporate a lot of behaviour.

Models are expressed as a collection of classes written in C#. Each class represents an entity (a.k.a. business object, domain object) within the application domain.

The following example illustrates a minimal model for an application that is concerned with books and their authors:

public class Author
    public int AuthorId { get; set; }
    public string LastName { get; set; }
    public List<Book> Titles { get; set; } = new List<Book>();

public class Book
    public int BookId { get; set; }
    public string Title { get; set; }
    public Author Author { get; set; }

When working with Entity Framework Core, it is usual for the model structure to closely match the schema of the database.

Model Diagram

Database Diagram

If the model differs from the database schema, it can be mapped to the target tables and columns using the Fluent API configuration capability of Entity Framework Core.

The model can be designed by hand coding, or it can be reverse engineered from an existing database.