Entity Framework EFAuditing Discover How to Perform Auditing
Definition
EFAuditing is a library that implements Auditing for Entity Framework Core based DbContexts. It is extensible to allow other logging providers like MongoDB, Azure tables etc.
Derive your context from AuditDbContext.
public partial class MyContext : AuditingDbContext { public MyContext() : base("MyContextDB") { this.Configuration.LazyLoadingEnabled = false; } public DbSet<Customer> Customers { get; set; } public DbSet<Invoice> Invoices { get; set; } public DbSet<InvoiceItem> InvoiceItems { get; set; } }
Use the overloaded SaveChanges(string userName) instead of the standard SaveChanges().
using (var context = new EnumTestContext()) { // code here context.SaveChanges("UserName"); }
Requirements
Entity Framework Version
- Entity Framework 6 or later.
ZZZ Projects