Files
components/LiteCharms.Features/Postgres/DataProtectionDbContextFactory.cs
T
Khwezi Mngoma cf439c5006
continuous-integration/drone/pr Build is passing
Ensure uninherited types are sealed
Resolved mediator source geenrator conflict with tests
2026-06-15 10:27:44 +02:00

21 lines
783 B
C#

using static LiteCharms.Features.Extensions.Postgres;
namespace LiteCharms.Features.Postgres;
public sealed class DataProtectionDbContextFactory : IDesignTimeDbContextFactory<DataProtectionDbContext>
{
public DataProtectionDbContext CreateDbContext(string[] args)
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddUserSecrets(typeof(DataProtectionDbContext).Assembly)
.AddEnvironmentVariables()
.Build();
var optionsBuilder = new DbContextOptionsBuilder<DataProtectionDbContext>();
optionsBuilder.UseNpgsql(configuration.GetConnectionString(DataProtectionDbConfigName));
return new DataProtectionDbContext(optionsBuilder.Options);
}
}