Thunder.EfCore.AuditTrail 1.1.0

dotnet add package Thunder.EfCore.AuditTrail --version 1.1.0
NuGet\Install-Package Thunder.EfCore.AuditTrail -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Thunder.EfCore.AuditTrail" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Thunder.EfCore.AuditTrail --version 1.1.0
#r "nuget: Thunder.EfCore.AuditTrail, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Thunder.EfCore.AuditTrail as a Cake Addin
#addin nuget:?package=Thunder.EfCore.AuditTrail&version=1.1.0

// Install Thunder.EfCore.AuditTrail as a Cake Tool
#tool nuget:?package=Thunder.EfCore.AuditTrail&version=1.1.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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 147 7/26/2023
1.0.0 138 7/25/2023

This library is brand new and has limited features.