Prodest.AuditNET
6.0.10
dotnet add package Prodest.AuditNET --version 6.0.10
NuGet\Install-Package Prodest.AuditNET -Version 6.0.10
<PackageReference Include="Prodest.AuditNET" Version="6.0.10" />
paket add Prodest.AuditNET --version 6.0.10
#r "nuget: Prodest.AuditNET, 6.0.10"
// 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 | Versions 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. |
-
net6.0
- Audit.EntityFramework.Core (>= 22.0.1)
- Microsoft.EntityFrameworkCore.SqlServer (>= 6.0.25)
- Prodest.Common (>= 6.0.10)
-
net7.0
- Audit.EntityFramework.Core (>= 22.0.1)
- Microsoft.EntityFrameworkCore.SqlServer (>= 7.0.14)
- Prodest.Common (>= 6.0.10)
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 |