using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; /// /// Creates for EF tools and migration bundles without /// running Program.cs (JWT and other runtime config are not available there). /// ./migrate-api --connection still overrides the connection at apply time. /// public sealed class AppDbContextFactory : IDesignTimeDbContextFactory { public AppDbContext CreateDbContext(string[] args) { var connectionString = Environment.GetEnvironmentVariable("ConnectionStrings__DefaultConnection") ?? "Host=localhost;Port=5436;Database=vigilcare;Username=postgres;Password=password"; var options = new DbContextOptionsBuilder() .UseNpgsql(connectionString) .Options; return new AppDbContext(options); } }