Implemented security functionality

Added data protection feature
Migrated changes
This commit is contained in:
2026-08-20 15:15:54 +02:00
parent 5ab977e335
commit 32a80eb84d
27 changed files with 735 additions and 37 deletions
@@ -0,0 +1,24 @@
using static PostFundManagement.Infrastructure.Extensions.Postgres;
namespace PostFundManagement.Infrastructure.Database.Factories;
public sealed class ApplicationDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
{
public ApplicationDbContext CreateDbContext(string[] args)
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddUserSecrets<IInfrastructure>(optional: true)
.AddEnvironmentVariables()
.Build();
var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
var connectionString = configuration.GetConnectionString(DatabaseConfigName)
?? throw new InvalidOperationException($"Connection string '{DatabaseConfigName}' was not found in configuration.");
optionsBuilder.UseNpgsql(connectionString, npgsqlOptions => npgsqlOptions.MigrationsAssembly(typeof(ApplicationDbContext).Assembly.FullName));
return new ApplicationDbContext(optionsBuilder.Options);
}
}