Prodest.AuditNET 6.0.10

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

// Install Prodest.AuditNET as a Cake Tool
#tool nuget:?package=Prodest.AuditNET&version=6.0.10

Prodest.AuditNET

Sobre

Pacote com a configuração necessária para realizar a auditoria de contextos do entity framework.

Como usar?

var builder = WebApplication.CreateBuilder(Environment.GetCommandLineArgs());

builder.Services
    .AddDbContext<WeatherDbContext>(
        (sp, options) => options
            .AddInterceptors(new AuditSaveChangesInterceptor())
            .UseSqlServer(
                sp.GetRequiredService<IConfiguration>()
                    .GetConnectionString("AuditLogConnection")
            )
    );

builder.Services
    .ConfigureSqlAudit();

var app = builder.Build();

await app.RunAsync();

Existem duas formas de habilitar a auditoria, a primeira é via a extensão IServiceCollection.AddDbContext, vide exemplo acima, já a segunda forma é adicionando o interceptor .AddInterceptors(new AuditSaveChangesInterceptor()) na sobrecarga do método OnConfiguring de uma classe de contexto que é derivada da classe DbContext:

internal sealed class WeatherDbContext : DbContext
{
    private readonly IConfiguration _configuration;

    public WeatherDbContext(IConfiguration configuration)
    {
        _configuration = configuration;
    }

    public DbSet<WeatherForecast> Forecasts { get; set; } = null!;

    /// <inheritdoc />
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.AddInterceptors(new AuditSaveChangesInterceptor())
            .UseSqlServer(_configuration.GetConnectionString("DefaultConnection"));
    }

    /// <inheritdoc />
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .Entity<WeatherForecast>(e =>
            {
                e.ToTable("WeatherForecast", "dbo");

                e.Property(x => x.ForecastId)
                    .ValueGeneratedOnAdd()
                    .HasColumnType("uniqueidentifier");

                e.Property(x => x.Date)
                    .IsRequired();

                e.Property(x => x.TemperatureC)
                    .IsRequired();

                e.Property(x => x.TemperatureF);

                e.Property(x => x.Summary)
                    .HasMaxLength(50)
                    .IsRequired();

                e.HasKey(y => y.ForecastId);
            })
            .HasAnnotation("Relational:Collation", "Latin1_General_CI_AS")
            .HasDefaultSchema("dbo");
    }
}

Após isso é necessário chamar a extensão que completa a configuração de auditoria na classe de startup:

builder.Services
    .ConfigureSqlAudit();
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 is compatible.  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
6.0.10 45 12/7/2023
6.0.9 44 11/27/2023
6.0.8 45 11/22/2023
6.0.7 28 11/21/2023
6.0.6 44 11/8/2023
6.0.2 58 10/17/2023
6.0.1 44 9/26/2023
6.0.1-preview.0.5 54 9/26/2023
6.0.1-preview.0.4 70 9/26/2023
6.0.1-preview.0.3 37 9/26/2023
6.0.1-preview.0.2 57 9/25/2023
6.0.1-preview.0.1 51 9/25/2023
6.0.0 52 9/21/2023
6.0.0-preview.0.1 50 9/21/2023