Back to Devexpress

Audit Trail Module (EF Core)

expressappframework-403104-data-security-and-safety-audit-trail-audit-trail-module-ef-core.md

latest3.7 KB
Original Source

Audit Trail Module (EF Core)

  • Oct 24, 2025
  • 5 minutes to read

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.

Audited Objects

The Audit Trail Module logs changes in the following objects and properties:

  • Persistent classes registered as DbSet<TEntity> properties in DbContext.
  • Public writable simple and reference properties defined in persistent classes.
  • Public collection properties defined in persistent classes.

Note

Add the Audit Trail Module to Your Application

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:

  1. Add the DevExpress.ExpressApp.AuditTrail.EFCore NuGet package to the application’s main module (MySolution.Module).

  2. 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.

  3. Register the Audit Trail Module in the ASP.NET Core Blazor and WinForms application projects:

  4. In both files, locate the code that configures the object space provider and replace the call to WithDbContext with WithAuditedDbContext as follows:

  5. 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.

Display Change History in the Object Detail View

Follow the steps below to show the history of an object in its detail view:

  1. Add the AuditDataItemPersistent collection property to your business class.

  2. 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