using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace New.Infrastructure.Persistence;
///
/// Design-time-only factory so `dotnet ef migrations add/update` can
/// construct a NewDbContext without a running host (this project has no DI
/// container of its own - New.Api's ServiceCollectionExtensions.AddPersistenceInfrastructure
/// is what wires the real DbContextOptions at runtime, reading
/// ConnectionStrings__New from the environment). Never used outside `dotnet ef`.
///
public sealed class NewDbContextFactory : IDesignTimeDbContextFactory
{
public NewDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=newdb;Username=postgres;Password=postgres");
return new NewDbContext(optionsBuilder.Options);
}
}