Auditing data with Envers
A common business requirement in application development is auditing changes to stored entities. Which entities were added, modified, or deleted? Who made the change? Which properties were modified?
In this recipe, we'll use NHibernate Envers, which provides exactly that kind of auditing functionality.
Getting ready
Complete the Eg.Core
model from Chapter 2, Models and Mappings.
How to do it…
- Create a new project named
Eg.Envers
. - Copy the
Eg.Core
model and mappings from Chapter 2, Models and Mappings to this new project. - Change the namespace and assembly references in the mappings to
Eg.Envers
. - Install NHibernate Envers using NuGet Package Manager Console, by executing the following command:
Install-Package NHibernate.Envers ...
Get NHibernate 4.x Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.