Entity Framework Audit Library

Introduction

Entity Framework Audit library allow you to log changes from EF change tracker in a database or log file.

Why using Audit with Entity Framework?

Common scenario:

  • To keep a history of change in a database or a log file
  • Track What/Who/When a modification occurs
  • Show historical data changes in a grid


Google – Related Searches


Stack Overflow – Related Questions


Example

// using Z.EntityFramework.Plus; // Don't forget to include this.
// AutoSave audit in a database
AuditManager.DefaultConfiguration.AutoSavePreAction = (context, audit) =>
(context as EntityContext).AuditEntries.AddRange(audit.Entries);
var ctx = new EntityContext();
// … ctx changes …
var audit = new Audit();
ctx.SaveChanges(audit);
// Access to all auditing information
var entries = audit.Entries;
foreach(var entry in entries)
{
foreach(var property in entry.Properties)
{
}
}

Supported Library

Library Type EF Version Support Doc Features
Z.EntityFramework.Plus FREE EF5
EF6
EF Core
< 1 Day Yes
  • Audit
  • Batch Delete
  • Batch Update
  • Cache
  • Deferred Query
  • Filter
  • Future
  • Include Filter
  • Include Optimized
Audit.entityframework FREE EF6
EF Core
< 1 Day Yes
  • Audit
Love.Net.EF.AutoHistory FREE EF Core < 1 Day No
  • Audit

Unsuported Library

Use them at your risk!

Library Type EF Version Support Doc Features
AuditDbContext FREE EF6 No Yes
  • Audit
EFAuditing FREE EF Core No No
  • Audit
EntityFramework.Extended FREE EF5
EF6
No Yes
  • Audit
  • Batch Delete
  • Batch Update
  • Cache
  • Future
TrackerEnabledDbContext FREE EF6 No Yes
  • Audit