liveBook · Manning

Deletion

As explained in ASP.NET Core in Action, 3e

Remove is an Entity Framework Core method that marks an entity for deletion when changes are saved.

Entity Framework Core’s Remove method marks an entity for deletion when changes are saved. Consider whether permanent deletion is appropriate before using it. section 12.6

Remove is a data-persistence operation; HTTP DELETE is a request verb for an API endpoint. An API can use that verb to request deletion, but the verb and the EF Core method are not the same thing. section 5.2.2 section 12.6

Before deleting an entity, consider whether a soft delete is a better fit:

  • A soft delete can use an IsDeleted flag and may be safer and easier to implement. section 12.6
Table 5.1 The minimal API map endpoints and the corresponding HTML verbs (view table figure)

Method

HTTP verb

Expected operation

MapGet(path, handler)

GET

Fetch data only; no modification of state. May be safe to cache.

MapPost(path, handler)

POST

Create a new resource.

MapPut(path, handler)

PUT

Create or replace an existing resource.

MapDelete(path, handler)

DELETE

Delete the given resource.

MapPatch(path, handler)

PATCH

Modify the given resource.

MapMethods(path, methods, handler)

Multiple verbs

Multiple operations.

Map(path, handler)

All verbs

Multiple operations.

MapFallback(handler)

All verbs

Useful for SPA fallback routes.

Compare HTTP verbs to see where DELETE fits in an API; this describes endpoint behavior, not EF Core’s entity-removal method. section 5.2.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Names Remove and cautions about deletion, without detailing its implementation.
Examples
Uses an IsDeleted flag as an example of a soft-delete alternative.
What you can do after
Evaluate whether entity deletion should be permanent or use a soft-delete flag.
How it connects
Distinguishes EF Core entity removal from HTTP DELETE and connects deletion to soft deletes.

Also explained in

Compare how 8 books explain deletion →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.