EfCore.SoftDeleteServices
9.0.0
dotnet add package EfCore.SoftDeleteServices --version 9.0.0
NuGet\Install-Package EfCore.SoftDeleteServices -Version 9.0.0
<PackageReference Include="EfCore.SoftDeleteServices" Version="9.0.0" />
paket add EfCore.SoftDeleteServices --version 9.0.0
#r "nuget: EfCore.SoftDeleteServices, 9.0.0"
// Install EfCore.SoftDeleteServices as a Cake Addin #addin nuget:?package=EfCore.SoftDeleteServices&version=9.0.0 // Install EfCore.SoftDeleteServices as a Cake Tool #tool nuget:?package=EfCore.SoftDeleteServices&version=9.0.0
EfCore.SoftDeleteServices
This library to provide simple soft delete and cascade soft delete in EF Core. It provides:
- Useful methods: The features in this library are:
- Set the SoftDeleted flag on an entity class, with checks.
- Provides a secure query to find all the Soft Deleted entities for a specific entity class.
- Reset the SoftDeleted flag on an entity class, which checks.
- Hard delete (i.e. call EF Core
Remove
method) a entity class, but only if it is already Soft Deleted.
NOTE: Methods can work with entity instance, or found via primary keys. Also has sync and async versions of all methods.
- Cascade Soft Delete: This library has a service that can mimic the database cascade delete, but Soft Deleting the entities. For instance, Cascade Soft Deleting a Company could also soft delete dependent relationships (see image below).
- Keeps your data secure: This library can handle Query Filters that contain multiple parts to the filter, e.g. Soft Delete with a multi-tenant filter. It builds queries that will replace the other filters so that your data stays secure.
- Fully configurable: It works with your properties and interfaces. The only rule it has is your Soft Delete property must provide true/false value (normally a 'bool', but could be part of enum status, etc.), or for the cascade delete it must provide a
byte
value. - DI-friendly: This library is designed to work with dependency injection (DI) and contains a method which will scan for your Soft Delete configuration files and set up all the services you need to use this library.
MIT License. Documentation can be found in the Repo's Wiki. NuGet available at EfCore.SoftDeleteServices.
List of versions and which .NET framework they support
- Version 9.0.0: supports NET 8 only (simpler to update to next NET release)
- Version 8.0.0: supports NET 8 only (simpler to update to next NET release)
- Version 4.?.?: Supports NET 6, 7 and 8
- Version 3.?.?: Supports NET 6 and 7
There are older versions of the EfCore.TestSupport library, but .NET lower than .NET 5 are not supported by Microsoft.
Normal (single) soft delete and cascade soft delete
Here is an image to show the difference between normal (single) soft delete and cascade soft delete.
The cascade soft delete is pretty clever, and can handle multi-level soft deletes - see this section from my article EF Core In depth - Soft deleting data with Global Query Filters.
Limitations
- When loading via keys it assumes the primary key property(s) are properties.
- The navigational links have to be properties.
All of these limitations could be removed, but it takes time to implement and check.
Terms
- Hard delete is when you delete a row in the database, via the EF Core
Remove
method. A hard delete removes the row from the database and may effect other entities/rows. - Single soft delete mimics a one row, hard delete. The entity/row is still in the database, but won't show up in EF Core query. But you can un-soft delete, referred to as a soft delete reset, and the makes the entity visible in an EF Core query.
- Cascade soft delete mimics the hard delete's cascade approach and will soft delete any dependant relationships (the EF Core
DeleteBehavior
has an effect on what happens). - Soft delete covers both Single soft delete and Cascade soft delete
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- GenericServices.StatusGeneric (>= 1.2.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.EntityFrameworkCore (>= 9.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.0)
- Microsoft.EntityFrameworkCore.Sqlite (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on EfCore.SoftDeleteServices:
Package | Downloads |
---|---|
Xswift.EntityFrameworkCore
Provides Implementations of the datasource abstraction that belongs to the XSwift frameworks. the implementations are based on the Entity framework core. |
|
Homox
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
9.0.0 | 152 | 11/21/2024 |
8.0.0 | 3,465 | 4/10/2024 |
4.0.0 | 2,088 | 11/22/2023 |
3.1.0 | 17,078 | 12/7/2022 |
2.0.2 | 9,471 | 6/18/2022 |
2.0.1 | 18,404 | 3/4/2022 |
2.0.0 | 3,416 | 11/10/2021 |
2.0.0-preview001 | 181 | 11/2/2021 |
1.1.3 | 2,024 | 3/13/2021 |
1.1.2 | 1,045 | 1/25/2021 |
1.1.1 | 840 | 1/22/2021 |
1.1.0 | 824 | 1/12/2021 |
1.0.0 | 2,002 | 1/9/2021 |
1.0.0-preview004 | 668 | 1/8/2021 |
1.0.0-preview003 | 665 | 1/8/2021 |
1.0.0-preview002 | 678 | 1/8/2021 |
1.0.0-preview001 | 691 | 1/8/2021 |
.NET 9 version