FrontLook.IAutoHistory 8.24.525.22

dotnet add package FrontLook.IAutoHistory --version 8.24.525.22                
NuGet\Install-Package FrontLook.IAutoHistory -Version 8.24.525.22                
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="FrontLook.IAutoHistory" Version="8.24.525.22" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FrontLook.IAutoHistory --version 8.24.525.22                
#r "nuget: FrontLook.IAutoHistory, 8.24.525.22"                
#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 FrontLook.IAutoHistory as a Cake Addin
#addin nuget:?package=FrontLook.IAutoHistory&version=8.24.525.22

// Install FrontLook.IAutoHistory as a Cake Tool
#tool nuget:?package=FrontLook.IAutoHistory&version=8.24.525.22                

AutoHistory

A plugin for Microsoft.EntityFrameworkCore to support automatically recording data changes history.

How to use

AutoHistory will recording all the data changing history in one Table named AutoHistories, this table will recording data UPDATE, DELETE history.

  1. Install AutoHistory Package

Run the following command in the Package Manager Console to install Microsoft.EntityFrameworkCore.AutoHistory

PM> Install-Package Microsoft.EntityFrameworkCore.AutoHistory

  1. Enable AutoHistory
public class BloggingContext : DbContext
{
    public BloggingContext(DbContextOptions<BloggingContext> options)
        : base(options)
    { }

    public DbSet<Blog> Blogs { get; set; }
    public DbSet<Post> Posts { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // enable auto history functionality.
        modelBuilder.EnableAutoHistory();
    }
}
  1. Ensure AutoHistory in DbContext. This must be called before bloggingContext.SaveChanges() or bloggingContext.SaveChangesAsync().
bloggingContext.EnsureAutoHistory()

Use Custom AutoHistory Entity

You can use a custom auto history entity by extending the Microsoft.EntityFrameworkCore.AutoHistory class.

class CustomAutoHistory : AutoHistory
{
    public String CustomField { get; set; }
}

Then register it in the db context like follows:

modelBuilder.EnableAutoHistory<CustomAutoHistory>(o => { });

Then provide a custom history entity creating factory when calling EnsureAutoHistory. The example shows using the factory directly, but you should use a service here that fills out your history extended properties(The properties inherited from AutoHistory will be set by the framework automatically).

db.EnsureAutoHistory(() => new CustomAutoHistory()
                    {
                        CustomField = "CustomValue"
                    });

Integrate AutoHistory into other Package

Microsoft.EntityFrameworkCore.UnitOfWork had integrated this package.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FrontLook.IAutoHistory:

Package Downloads
FrontLookCoreLibraryAssembly.Hosting.DbContext

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.24.525.22 152 5/25/2024
8.24.525.19 139 5/25/2024
8.24.524.14 147 5/24/2024
8.24.524.13 140 5/24/2024
8.24.505.19 142 5/5/2024
8.24.504 123 5/3/2024
8.24.502.15 91 5/2/2024
8.24.427.18 149 4/27/2024
8.24.421.10 118 4/21/2024
8.24.421.8 118 4/21/2024
8.24.407.1 158 4/6/2024
8.24.401.12 131 4/1/2024
8.24.401.2 136 3/31/2024
8.24.331.13 130 3/31/2024
8.24.323.1623 126 3/23/2024
8.24.323.1520 146 3/23/2024
8.24.323.23 153 3/23/2024