Merge pull request 'Refactored RegisterDbContexts to ignore pending changes rule' (#22) from setup into master
Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
@@ -1,25 +1,27 @@
|
|||||||
// Copyright (c) Jan Škoruba. All Rights Reserved.
|
// Copyright (c) Jan Škoruba. All Rights Reserved.
|
||||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||||
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using HealthChecks.UI.Client;
|
using HealthChecks.UI.Client;
|
||||||
|
using LiteCharmsSecurity.Admin.Api.Configuration;
|
||||||
|
using LiteCharmsSecurity.Admin.EntityFramework.Shared.DbContexts;
|
||||||
|
using LiteCharmsSecurity.Admin.EntityFramework.Shared.Entities.Identity;
|
||||||
|
using LiteCharmsSecurity.Shared.Dtos;
|
||||||
|
using LiteCharmsSecurity.Shared.Dtos.Identity;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using NSwag.AspNetCore;
|
using NSwag.AspNetCore;
|
||||||
using Skoruba.AuditLogging.EntityFramework.Entities;
|
using Skoruba.AuditLogging.EntityFramework.Entities;
|
||||||
using LiteCharmsSecurity.Admin.Api.Configuration;
|
|
||||||
using Skoruba.Duende.IdentityServer.Admin.EntityFramework.Configuration.Configuration;
|
using Skoruba.Duende.IdentityServer.Admin.EntityFramework.Configuration.Configuration;
|
||||||
using LiteCharmsSecurity.Admin.EntityFramework.Shared.DbContexts;
|
|
||||||
using LiteCharmsSecurity.Admin.EntityFramework.Shared.Entities.Identity;
|
|
||||||
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Configuration;
|
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Configuration;
|
||||||
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Helpers;
|
using Skoruba.Duende.IdentityServer.Admin.UI.Api.Helpers;
|
||||||
using Skoruba.Duende.IdentityServer.Shared.Configuration.Helpers;
|
using Skoruba.Duende.IdentityServer.Shared.Configuration.Helpers;
|
||||||
using LiteCharmsSecurity.Shared.Dtos;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using LiteCharmsSecurity.Shared.Dtos.Identity;
|
|
||||||
using StartupHelpers = Skoruba.Duende.IdentityServer.Shared.Configuration.Helpers.StartupHelpers;
|
using StartupHelpers = Skoruba.Duende.IdentityServer.Shared.Configuration.Helpers.StartupHelpers;
|
||||||
|
|
||||||
namespace LiteCharmsSecurity.Admin.Api
|
namespace LiteCharmsSecurity.Admin.Api
|
||||||
@@ -109,6 +111,13 @@ namespace LiteCharmsSecurity.Admin.Api
|
|||||||
DatabaseMigrationsConfiguration databaseMigration)
|
DatabaseMigrationsConfiguration databaseMigration)
|
||||||
{
|
{
|
||||||
services.AddDbContexts<AdminIdentityDbContext, IdentityServerConfigurationDbContext, IdentityServerPersistedGrantDbContext, AdminLogDbContext, AdminAuditLogDbContext, IdentityServerDataProtectionDbContext, AdminConfigurationDbContext, AuditLog>(Configuration, databaseMigration);
|
services.AddDbContexts<AdminIdentityDbContext, IdentityServerConfigurationDbContext, IdentityServerPersistedGrantDbContext, AdminLogDbContext, AdminAuditLogDbContext, IdentityServerDataProtectionDbContext, AdminConfigurationDbContext, AuditLog>(Configuration, databaseMigration);
|
||||||
|
|
||||||
|
// 2. Intercept the DbContextOptions configurations in the DI container and inject the ignore rule
|
||||||
|
services.Configure<DbContextOptionsBuilder<AdminIdentityDbContext>>(options =>
|
||||||
|
options.ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning)));
|
||||||
|
|
||||||
|
services.Configure<DbContextOptionsBuilder<IdentityServerConfigurationDbContext>>(options =>
|
||||||
|
options.ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void RegisterAuthentication(IServiceCollection services)
|
public virtual void RegisterAuthentication(IServiceCollection services)
|
||||||
|
|||||||
Reference in New Issue
Block a user