NHibernate Envers is like an audit trail with Entity Framework 6+

NHibernate Envers does a good job of creating an audit trail whenever an object is updated / deleted. Basically, he creates an audit table for each object being checked and writes a snapshot of the data to the audit table. E.g. if Customer records are stored in the CUSTOMER table, then the audit log for Customer records will be saved in the CUSTOMER_AUD table.

In one of my projects, we use Entity Framework 6.1. I searched and reviewed various alternatives, such as AuditDBContext and EntityFramework Extensions , but none of them provide a boxed solution similar to NHibernate Envers.

I think that creating an audit trail should be a fairly common requirement, so my question is, is there any of the off-the-shelf solutions for EF 6+ that generates an audit trail similar to NHibernate Envers?

+4
source share
2 answers

As a result, I created a custom solution using AuditDBContext .

Basically, I use AuditDBContext to track which properties have been changed, and then use it to write information to audit tables. Audit tables accurately reflect the main tables with two additional columns:

  • REV_TYPE - indicates that the type of revision can be Add / Update / Delete
  • REV_ID - .
+1

Source: https://habr.com/ru/post/1544853/


All Articles