Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Libraries/Infrastructure/DatabaseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ public static class DatabaseExtensions
{
public static IHostApplicationBuilder AddDatabaseServices(this IHostApplicationBuilder builder)
{
if (!builder.Services.Any(x => x.ServiceType == typeof(ICurrentUserService)))
{
throw new InvalidOperationException(
"ICurrentUserService must be registered before calling AddDatabaseServices. " +
"Register an implementation using builder.Services.AddScoped<ICurrentUserService, YourImplementation>()");
}

builder.Services.AddScoped<AuditSaveChangesInterceptor>();

builder.Services.AddDbContext<AuditContext>((sp, options) =>
Expand Down
Loading