Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audit for EF Core

I would like to implement audit functionality using EF Core.

I mean would like to log every transaction/action such as Create, update and delete in DB table.

I have searched on google and found some library and solution.

https://www.nuget.org/packages/Audit.EntityFramework.Core/

https://beeming.net/data/2017/1/easily-adding-auditing-to-a-entity-framework-code-first-project

Can some one suggest me best practices for auditing for EF Core Note: I am using EF Core 2.X

like image 600
itmannz Avatar asked Jul 22 '26 08:07

itmannz


1 Answers

The basic process for auditing is to override the SaveChanges() method on the DbContext and plug in some logic. The DbContext has a ChangeTracker property that makes it super easy to access the before and after values

like image 139
Robert Perry Avatar answered Jul 24 '26 05:07

Robert Perry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!