AuditedDbContextBuilderExtensions.WithAuditedDbContext<TContext>(DbContextBuilder<TContext>, Action<AuditedDbContextConfigurator>, ServiceLifetime) Method
Allows you to configure 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.2.dll
NuGet Package: DevExpress.ExpressApp.AuditTrail.EFCore
Declaration
public static IObjectSpaceProviderBuilder<TContext> WithAuditedDbContext<TContext>(
this DbContextBuilder<TContext> dbContextBuilder,
Action<AuditedDbContextConfigurator> configureContexts,
ServiceLifetime dbContextFactoryServiceLifetime = ServiceLifetime.Scoped
)
where TContext : IXafApplicationBuilder<TContext>, IAccessor<IServiceCollection>
Parameters
Name | Type | Description |
---|---|---|
dbContextBuilder | DbContextBuilder<TContext> | Allows you to configure |
configureContexts | Action<AuditedDbContextConfigurator> | A delegate that configures |
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
dbContextFactoryServiceLifetime | ServiceLifetime | Scoped | A ServiceLifetime enumeration value that specifies the lifetime of the |
Type Parameters
Name | Description |
---|---|
TContext | The IWinApplicationBuilder type. |
Returns
Type | Description |
---|---|
IObjectSpaceProviderBuilder<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.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 => {
// ...
});
});
}
// ...
}