expressappframework-403104-data-security-and-safety-audit-trail-audit-trail-module-ef-core.md
This topic describes how to add the Audit Trail Module to your ASP.NET Core Blazor or WinForms application and explains the Module’s features specific to the Entity Framework Core ORM.
The Audit Trail Module logs changes in the following objects and properties:
Note
false.Follow the steps below to add the Audit Trail Module to your application. If you added this Module when you created an XAF application, the Template Kit generates the described code automatically:
Add the DevExpress.ExpressApp.AuditTrail.EFCore NuGet package to the application’s main module (MySolution.Module).
Add a new DbContext used to store audit trail records to the application’s main module and register the AuditDataItemPersistent and AuditEFCoreWeakReference types both in this DbContext and in the application’s main DbContext.
Register the Audit Trail Module in the ASP.NET Core Blazor and WinForms application projects:
In both files, locate the code that configures the object space provider and replace the call to WithDbContext with WithAuditedDbContext as follows:
Run the application and click the Reports | Audit Event navigation item. The invoked list view contains change history for audited objects.
ASP.NET Core Blazor
WinForms
Note
The AuditInformationReadonlyViewController does not allow users to create, edit, or delete IAuditDataItemPersistent objects from the UI.
Follow the steps below to show the history of an object in its detail view:
Add the AuditDataItemPersistent collection property to your business class.
In applications with the Security System, configure permissions for non-administrative user roles so users can read information on their changes only.
The images below demonstrate the result:
ASP.NET Core Blazor
WinForms
Tip
You can also access the audit log in the database directly if you do not want to display history in the UI.
See Also
XAF - How to show audit entries for a current object and its aggregated objects in one list