8 Configuring advanced features and handling concurrency conflicts
This chapter covers
- Using backing fields with relationships
- Using an SQL user-defined function in EF Core
- Configuring SQL column properties
- Handling concurrency conflicts
This chapter starts with more-advanced approaches to working with a database. These include a method to “hide” a relationship from outside changes, and various ways to move calculations into the database. Then we’ll cover several configuration features that aren’t the normal, run-of-the-mill features, but provide access or control of columns in the database. Although you won’t use these features every day, they can be useful in specific circumstances.
The second half of this chapter is about handling multiple, near-simultaneous updates of the same piece of data in the database; these updates can cause problems known as concurrency conflicts. By default, EF Core uses an Optimistic Concurrency pattern, meaning it’ll take the last value that was written to the database. You’ll learn how to configure just one property/column or a whole entity/table to catch concurrency conflicts, and how to capture and then write code to correct the concurrency conflict.