using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; namespace Svrnty.Sample.Data; /// /// Design-time factory for creating AgentDbContext during migrations /// public class AgentDbContextFactory : IDesignTimeDbContextFactory { public AgentDbContext CreateDbContext(string[] args) { var optionsBuilder = new DbContextOptionsBuilder(); // Use a default connection string for design-time operations // This will be overridden at runtime with the actual connection string from configuration var connectionString = Environment.GetEnvironmentVariable("CONNECTION_STRING_SVRNTY") ?? "Host=localhost;Database=svrnty;Username=postgres;Password=postgres;Include Error Detail=true"; optionsBuilder.UseNpgsql(connectionString, npgsqlOptions => { npgsqlOptions.MigrationsHistoryTable("__EFMigrationsHistory", "agent"); }); return new AgentDbContext(optionsBuilder.Options); } }