Azrng.EFCore.AutoAudit 1.0.0-beat1

This is a prerelease version of Azrng.EFCore.AutoAudit.
dotnet add package Azrng.EFCore.AutoAudit --version 1.0.0-beat1
                    
NuGet\Install-Package Azrng.EFCore.AutoAudit -Version 1.0.0-beat1
                    
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="Azrng.EFCore.AutoAudit" Version="1.0.0-beat1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Azrng.EFCore.AutoAudit" Version="1.0.0-beat1" />
                    
Directory.Packages.props
<PackageReference Include="Azrng.EFCore.AutoAudit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Azrng.EFCore.AutoAudit --version 1.0.0-beat1
                    
#r "nuget: Azrng.EFCore.AutoAudit, 1.0.0-beat1"
                    
#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.
#:package Azrng.EFCore.AutoAudit@1.0.0-beat1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Azrng.EFCore.AutoAudit&version=1.0.0-beat1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Azrng.EFCore.AutoAudit&version=1.0.0-beat1&prerelease
                    
Install as a Cake Tool

Azrng.EFCore.AutoAudit

一个EFCore自动审计的包

预操作

需要手动提前创建审计表,pgsql示例如下

create table public.audit_record
(
    id             varchar(50)              not null
        constraint audit_record_pk
            primary key,
    table_name     varchar(120),
    operation_type integer,
    object_id      text,
    origin_value   text,
    new_value      text,
    extra          text,
    updater        text,
    update_time    timestamp with time zone not null,
    succeeded      boolean                  not null
);

comment on table public.audit_record is '审计记录表';

comment on column public.audit_record.table_name is '表名';

comment on column public.audit_record.operation_type is '操作类型 0查询,1添加,2修改,3删除';

comment on column public.audit_record.origin_value is '老值';

comment on column public.audit_record.new_value is '新值';

comment on column public.audit_record.extra is '扩展';

comment on column public.audit_record.updater is '更新人';

comment on column public.audit_record.update_time is '更新时间';

comment on column public.audit_record.succeeded is '是否成功';

操作

默认自动审计

// 添加业务数据库
builder.Services.AddDbContext<OpenDbContext>((provider, options) =>
{
    options.UseNpgsql(conn);
    options.AddAuditInterceptor(provider);
});

// 添加审计
builder.Services.AddEFCoreAutoAudit(config =>
{
    config // .WithStore<AuditFileStore>() // 自定义存储
        .WithAuditRecordsDbContextStore(options => { options.UseNpgsql(conn); });
});

忽略指定表

services.AddEFCoreAutoAudit(builder =>
{
    builder.IgnoreEntity<Test2Entity>() // 忽略指定表 还可以IgnoreTable("test2")
        .WithAuditRecordsDbContextStore(options => { options.UseSqlite("Data Source=d:\\db\\AutoAudit.db");    });
});

版本更新记录

  • 1.0.0-beta1
    • EFCore自动审计包
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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.0.0-beat1 179 8/9/2025