No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/AuditTrail
.gitattributes
.gitignore
AuditTrail.sln
README.md
global.json

README.md

Audit Trail

####Entities changes audit

This is the result of a job interview exercise I was asked to perform.

The purpose is to create an automatic system that logs any changes to any entity in your database.

Using .NET Core and EntityFramework Core 1.0.0 I created a little console app to seed the DB, randomly change the records and list the log.

Inspired by a Julie Lerman Pluralsight course (can't remember which one) and a nice post by Matthew P Jones, it seems that overriding the SaveChanges method of the DbContex is probably the best way to go. In Julie course she has all her entities inherit from an interface that expose Id, DateModified, DateCreated and User and she automatically log this information within the entityobject. By overriding the SaveChanges method we have access to all the properties that are being affected along with the OriginalValue and NewValues so we can log each property change accordingly (see AuditContext class).