6 Configuring nonrelational properties
This chapter covers
- Configuring EF Core
- Focusing on nonrelational properties
- Defining the database structure
- Using shadow properties and backing fields
This chapter is the first of three that look at configuring EF Core, and it concentrates on configuring the nonrelational properties in an entity class, known as scalar properties. Chapter 7 covers configuring relational properties, and chapter 8 covers configuring more advanced features, such as DbFunctions, computed columns, and so on.
This chapter starts with an overview of the configuration process that EF Core runs when the application’s DbContext is used for the first time. You’ll then learn how to configure the mapping between the .NET classes and their associated database tables, with features such as setting the name, SQL type, and nullability of the columns in a table.
This chapter also introduces two EF Core features—shadow properties and backing fields —that enable you to control how the data is exposed to the rest of your non-EF Core code. For instance, these features allow you to “hide,” or control access to, data linked to your database. These two features can help you write better, less fragile applications through better control of the developer’s access to the data held in the entity class.