...

/

Modifying Data with EF Core: Insert Entities

Modifying Data with EF Core: Insert Entities

Learn about inserting entities in EF Core, maintaining change tracking with DbContext, and calling SaveChanges to commit changes to the database.

We'll cover the following...

Inserting, updating, and deleting entities using EF Core is an easy task to accomplish. DbContext maintains change tracking automatically so the local entities can track multiple changes, including adding new entities, modifying existing entities, and removing entities. Call the SaveChanges method when ready to send those changes to the underlying database. The number of entities successfully changed will be returned.

Inserting entities

Let’s start by looking at how to add a new row to a table: ...