Chapter 2 covered querying a database. This chapter moves on to changing the content of a database. Changing data has three distinct parts—creating new rows in a database table, updating existing rows in a database table, and deleting rows in a database table—and I cover them in that order. Create, update, and delete, along with read (which is query in EF Core terms) are database terms for what’s happening, and the foursome is often shortened to CRUD.
You’ll use the same database as in chapter 2, which has the Book, PriceOffer, Review, BookAuthor, and Author entity classes. These classes provide a good selection of property types and relationships that you can use to learn the various issues and approaches to changing data in a database via EF Core.
Before I start describing the methods to add, update, or delete entities, I want to introduce you to EF Core’s entity property, called State. This property provides another look under the hood at the way EF Core does things, which helps you understand what’s going on when you add, update, or delete entities.