Install-Package EFCore.SoftDelete -Version 1.3.0
dotnet add package EFCore.SoftDelete --version 1.3.0
<PackageReference Include="EFCore.SoftDelete" Version="1.3.0" />
paket add EFCore.SoftDelete --version 1.3.0
#r "nuget: EFCore.SoftDelete, 1.3.0"
// Install EFCore.SoftDelete as a Cake Addin #addin nuget:?package=EFCore.SoftDelete&version=1.3.0 // Install EFCore.SoftDelete as a Cake Tool #tool nuget:?package=EFCore.SoftDelete&version=1.3.0
Ef Core Soft Delete implementation
A very simple implementation for soft deleting entities in Ef Core library.
Extend your application db context from
In entities you want to add soft delete support, implement
It will a column named
DeletedAt to your entity so you need to add a migration and update the database tables.
Load relations you want to delete in soft deleting the entity in
Delete relations you want to delete in soft deleting the entity in
For soft deleting an entity use
RemoveAsync methods. These methods will
soft delete an
ISoftDelete implemented entity and force delete an not implemented entity.
For force deleting any entity use
For restoring soft-deleted entities, you can use
Note that this methods will no longer call
SaveChanges method. For better performance, you should manually call
It doesn't support
DbSet yet, so you have to use
SoftDeletes.Core.DbContext methods for removing instead of using
An interface for saving
UpdatedAt date and time of entities.
You can implement it in your entities. That will add to columns named
UpdatedAt to your entities.
ModelExtenstion abstract class:
An abstract class that implements
You can use it in your entities.
sample project for this implementation.
If you like it, you can support me with
The proposal for this implementation.
|.NET||net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows|
- Microsoft.EntityFrameworkCore (>= 6.0.1)
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.