using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace Deal.Infrastructure.Persistence;
///
/// Фабрика для dotnet-ef
///
public sealed class TenantDbDesignTimeFactory : IDesignTimeDbContextFactory
{
public TenantDbContext CreateDbContext(string[] args)
{
string connectionString = Environment.GetEnvironmentVariable("DEAL_PG_CONNECTION")
?? "Host=localhost;Port=5433;Database=deal;Username=deal;Password=deal_dev_password";
var options = new DbContextOptionsBuilder()
.UseNpgsql(connectionString, npgsql => npgsql.MigrationsHistoryTable("__TenantMigrationsHistory"))
.Options;
return new TenantDbContext(options);
}
}