Thunder.EfCore.AuditTrail
1.0.0
See the version list below for details.
dotnet add package Thunder.EfCore.AuditTrail --version 1.0.0
NuGet\Install-Package Thunder.EfCore.AuditTrail -Version 1.0.0
<PackageReference Include="Thunder.EfCore.AuditTrail" Version="1.0.0" />
paket add Thunder.EfCore.AuditTrail --version 1.0.0
#r "nuget: Thunder.EfCore.AuditTrail, 1.0.0"
// Install Thunder.EfCore.AuditTrail as a Cake Addin #addin nuget:?package=Thunder.EfCore.AuditTrail&version=1.0.0 // Install Thunder.EfCore.AuditTrail as a Cake Tool #tool nuget:?package=Thunder.EfCore.AuditTrail&version=1.0.0
Thunder.EfCore.AuditTrail
Provides a configurable audit trail that can capture any entity changes done via EF Core, and exposes a way to manage this audit trail.
How to Use
Currently, the only way to use this is to inherit from AuditDbTrail<TEntityKey>
:
public class BloggingContext : AuditTrailContext<Int32>
{
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
}
The TEntityKey
is the type of key for the entities you have. This allows the library to fetch the primary key without requiring much configuration. The entities would also need to have the IAuditTrailEntity<TEntityKey>
interface applied:
public class Blog : IAuditTrailEntity<Int32>
{
public Int32 Id { get; set; }
public String BlogName { get; set; } = "";
}
public class Post : IAuditTrailEntity<Int32>
{
public Int32 Id { get; set; }
public String PostTitle { get; set; } = "";
}
The context exposes an audit trail via the DbSets AuditTrail
.
Why?
This exists to abstract away the reading/writing of a JSON file and to combine it easily with the IFile
interface.
Roadmap
There are plans to let the configuration of this to be applied on a per-entity basis based on the Entity Model Configuration. e.g:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<PantryItem>().HasKey(x => x.Id).UseAuditTrail();
modelBuilder.Entity<ShoppingListItem>().HasKey(x => x.Id).UseAuditTrail();
base.OnModelCreating(modelBuilder);
}
_context.PantryItems.GetAuditTrail()
The plan for the above is to let the system create an audit table for each entity, which means the table system could be optimized heavily.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- Microsoft.EntityFrameworkCore (>= 7.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
This library is brand new and has limited features.