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.

AuditedDbContextBuilderExtensions.WithAuditedDbContext<TContext>(DbContextServiceBasedBuilder<TContext>, Action<AuditedDbContextServiceBasedConfigurator>, ServiceLifetime) Method

Allows you to configure DbContext objects in ASP.NET Core Blazor 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 static IObjectSpaceProviderServiceBasedBuilder<TContext> WithAuditedDbContext<TContext>(
    this DbContextServiceBasedBuilder<TContext> dbContextBuilder,
    Action<AuditedDbContextServiceBasedConfigurator> configureContexts,
    ServiceLifetime dbContextFactoryServiceLifetime = ServiceLifetime.Scoped
)
    where TContext : IXafApplicationBuilder<TContext>, IAccessor<IServiceCollection>

Parameters

Name Type Description
dbContextBuilder DbContextServiceBasedBuilder<TContext>

Allows you to configure DbContext objects.

configureContexts Action<DevExpress.ExpressApp.ApplicationBuilder.AuditedDbContextServiceBasedConfigurator>

A delegate that configures DbContext objects.

Optional Parameters

Name Type Default Description
dbContextFactoryServiceLifetime ServiceLifetime Scoped

A ServiceLifetime enumeration value that specifies the lifetime of the DbContextFactory service registered by the WithAuditedDbContext method.

Type Parameters

Name Description
TContext

The IBlazorApplicationBuilder type.

Returns

Type Description
IObjectSpaceProviderServiceBasedBuilder<TContext>

Allows you to register and configure Object Space Providers in your application, and chain further provider registrations.

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 => {
                            // ...
                        });
                });
        });
        // ...
    }
}
See Also