• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Services to provide simple soft delete and cascade soft delete in EF Core

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 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.

Two types of 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

More Repositories

1

AuthPermissions.AspNetCore

This library provides extra authorization and multi-tenant features to an ASP.NET Core application.
C#
774
star
2

EfCore.GenericServices

A library to help you quickly code CRUD accesses for a web/mobile/desktop application using EF Core.
C#
598
star
3

EfCoreinAction-SecondEdition

Supporting repo to go with book "Entity Framework Core in Action", second edition
C#
397
star
4

EfCore.TestSupport

Tools for helping in unit testing applications that use Entity Framework Core
C#
353
star
5

EfCoreInAction

Supporting code to go with the book "Entity Framework Core in Action"
340
star
6

PermissionAccessControl2

Version 2 of example application to go with articles on feature and data authorization
C#
276
star
7

GenericServices

GenericServices helps with building a service/application layer in a .NET based application using EF6.x
C#
245
star
8

NetCore.AutoRegisterDi

Extension method to find/register classes in an assembly into the Microsoft DI provider
C#
234
star
9

PermissionAccessControl

Example code for Authorization articles
C#
224
star
10

EfCore.GenericBizRunner

Library to run business logic when using Entity Framework Core for database accesses
C#
216
star
11

AspNetReactSamples

Template/Sample ASP.NET projects to develop/build/test React.js apps
JavaScript
174
star
12

EfCore.SchemaCompare

Library to compare EF Core's Model of the database against a database's schema.
C#
106
star
13

Net.DistributedFileStoreCache

NET distributed cache using a json file as the shared resourse with very fast Get
C#
96
star
14

SampleMvcWebApp

A Sample MVC5 web application showing the use of GenericServices for CRUD operations
C#
75
star
15

EfCore.GenericEventRunner

A library to allow developer use events to update their database via Entity Framework Core (EF Core)
C#
67
star
16

EfCoreSqlAndCosmos

Example CQRS application using Cosmos DB with EF Core
C#
66
star
17

BookApp.All

Example of applying an modular monolith approach to building apps. This version contains the whole app in one solution
C#
50
star
18

EfCore.GenericServices.AspNetCore

Converts EFCore.GenericServices and EfCore.GenericBizRunner statuses to ASP.NET Core formats
C#
49
star
19

EfSchemaCompare

EfSchemaCompare.EF6 allows you to compare Entity Framework's database modal with an actual SQL database.
C#
44
star
20

RunStartupMethodsSequentially

A .NET library that runs methods within a locked state on startup. This is useful if you want to migrate or seed a database on an web application that has multiple instances.
C#
32
star
21

EfCore.SoftDeleteServices-Old

Services to provide simple soft delete and cascade soft delete in EF Core
C#
29
star
22

GenericServices.StatusGeneric

Implements the "return a status" pattern - useful for code that can return errors
C#
28
star
23

SampleMvcWebAppComplex

A more complex MVC application showing the use of GenericServices with the AdventureWorksLT2012 database.
C#
26
star
24

Net.LocalizeMessagesAndErrors

This library provides extra code to make it easier to support in different languages in your .NET application
C#
18
star
25

MvcUsingBower

Applying Visual Studio's Bower/Grunt tools to a ASP.NET MVC application. See
JavaScript
16
star
26

PermissionsOnlyApp

C#
15
star
27

DDDExampleCode

Example code to go with my talk and article on DDD
C#
13
star
28

MultiProgPackTool

https://www.thereformedprogrammer.net/evolving-modular-monoliths-2-breaking-up-your-app-into-multiple-solutions/#how-to-create-a-nuget-packages
C#
9
star
29

SimpleMessageBroker

C#
5
star
30

Ef6BookApp

C#
4
star
31

AspNetCore.MultipleHostedService

C#
3
star
32

AuthP.CustomDatabaseExamples

C#
2
star
33

BookApp.Books

Part of the evolving Modular Monalith
C#
2
star
34

TryAspNetCoreMigrate

C#
2
star
35

BookApp.Main

C#
2
star
36

TestSupportSchema

C#
1
star