Skip to main content
All docs
V24.1
.NET 6.0+
  • The page you are viewing does not exist in the .NET Framework 4.5.2+ platform documentation. This link will take you to the parent topic of the current section.

AuditedDbContextConfigurator.Configure<TBusinessObjectDbContext, TAuditHistoryDbContext>(Action<XafApplication, DbContextOptionsBuilder>, Action<XafApplication, DbContextOptionsBuilder>, Action<AuditTrailOptions>) Method

Configures the main (business object) and additional (audit history) DbContext objects in WinForms applications with the Audit Trail Module.

Namespace: DevExpress.ExpressApp.ApplicationBuilder

Assembly: DevExpress.ExpressApp.AuditTrail.EFCore.v24.1.dll

NuGet Package: DevExpress.ExpressApp.AuditTrail.EFCore

Declaration

public abstract void Configure<TBusinessObjectDbContext, TAuditHistoryDbContext>(
    Action<XafApplication, DbContextOptionsBuilder> configureBusinessObjectDbContext,
    Action<XafApplication, DbContextOptionsBuilder> configureAuditHistoryDbContext,
    Action<AuditTrailOptions> configureAuditTrailOptions = null
)
    where TBusinessObjectDbContext : DbContext where TAuditHistoryDbContext : DbContext

Parameters

Name Type Description
configureBusinessObjectDbContext Action<XafApplication, DbContextOptionsBuilder>

A delegate that configures the main application DbContext.

configureAuditHistoryDbContext Action<XafApplication, DbContextOptionsBuilder>

A delegate that configures the additional DbContext that the Audit Trail Module uses to store records.

Optional Parameters

Name Type Default Description
configureAuditTrailOptions Action<DevExpress.Persistent.BaseImpl.EFCore.AuditTrail.AuditTrailOptions> null

Options that you can use to configure the Audit Trail Module.

Type Parameters

Name Description
TBusinessObjectDbContext

The main application DbContext.

TAuditHistoryDbContext

The additional DbContext that the Audit Trail Module uses to store records.

Remarks

The following example demonstrates how to use this method:

File: MySolution.Blazor.Server\Startup.cs.

using DevExpress.ExpressApp.ApplicationBuilder;
using DevExpress.ExpressApp.Blazor.ApplicationBuilder;
// ...
public class Startup {
   // ...
    public void ConfigureServices(IServiceCollection services) {
        // ...
        services.AddXaf(Configuration, builder => {
            builder.UseApplication<MySolutionBlazorApplication>();
            builder.ObjectSpaceProviders
                // ...
                .AddSecuredEFCore()
                .WithAuditedDbContext(contexts => {
                    contexts.Configure<MySolutionDbContext, AuditingDbContext>(
                        (serviceProvider, businessObjectDbContextOptions) => {
                            // ...
                        },
                        (serviceProvider, auditHistoryDbContextOptions) => {
                            // ...
                        },
                        options => {
                            // ...
                        });
                });
        });
        // ...
    }
}

File: MySolution.Win\Startup.cs.

using DevExpress.ExpressApp.ApplicationBuilder;
using DevExpress.ExpressApp.Win.ApplicationBuilder;
// ...
public class ApplicationBuilder : IDesignTimeApplicationFactory {
    public static WinApplication BuildApplication(string connectionString) {
        var builder = WinApplication.CreateBuilder();
        builder.UseApplication<MySolutionWindowsFormsApplication>();
        builder.ObjectSpaceProviders
            .AddSecuredEFCore()
            .WithAuditedDbContext(contexts => {
                contexts.Configure<MySolutionDbContext, AuditingDbContext>(
                    (application, businessObjectDbContextOptions) => {
                        // ...
                    },
                    (application, auditHistoryDbContextOptions) => {
                        // ...
                    },
                    options => {
                        // ...
                    });
            });
    }
    // ...
}
See Also