Prodest.AuditNET
7.0.5
dotnet add package Prodest.AuditNET --version 7.0.5
NuGet\Install-Package Prodest.AuditNET -Version 7.0.5
<PackageReference Include="Prodest.AuditNET" Version="7.0.5" />
<PackageVersion Include="Prodest.AuditNET" Version="7.0.5" />
<PackageReference Include="Prodest.AuditNET" />
paket add Prodest.AuditNET --version 7.0.5
#r "nuget: Prodest.AuditNET, 7.0.5"
#:package Prodest.AuditNET@7.0.5
#addin nuget:?package=Prodest.AuditNET&version=7.0.5
#tool nuget:?package=Prodest.AuditNET&version=7.0.5
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net9.0 was computed. 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. |
-
net7.0
- Audit.EntityFramework.Core (>= 21.1.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 7.0.13)
- Prodest.Common (>= 7.0.5)
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 |
|---|