© Eric Vogel 2021
E. VogelBeginning Entity Framework Core 5https://doi.org/10.1007/978-1-4842-6882-7_10

10. Deleting Data

Eric Vogel1  
Okemos, MI, USA

In this chapter, I will cover how to delete data using Entity Framework Core 5. There are generally two ways to delete a record. These two methods are often referred to as soft delete and hard delete. A soft delete is flagging a record as deleted and can be achieved by doing a database update and setting a flag to mark a record as deleted. A hard delete is removing the record from the database, and it can no longer be retrieved afterward. In this chapter, I will be covering how to implement a hard delete.

Deleting the Root Entity

There are two steps to removing an item. The first is retrieving that ...

Get Beginning Entity Framework Core 5: From Novice to Professional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.