...
/Modifying Data with EF Core: Update, and Delete Entities
Modifying Data with EF Core: Update, and Delete Entities
Learn how to update and delete entities in EF Core with precise criteria to efficiently modify rows in a table.
We'll cover the following...
We'll cover the following...
Updating entities
Let’s modify an existing row in a table. We will find a product to update by specifying the start of a product name and only return the first match. In a real application, if we need to update a specific product, then we must use a unique identifier like ProductId
.
Let’s go:
Step 1: In Program.Modifications.cs
, add a method to increase the price of the first product with a name that begins with a specified value (we’ll use Bob in our example) by a specified amount like