22 lines
802 B
C#
22 lines
802 B
C#
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using Microsoft.EntityFrameworkCore.Design;
|
||
|
|
|
||
|
|
namespace TeamUp.Modules.Governance.Persistence;
|
||
|
|
|
||
|
|
/// <summary>Design-time factory so `dotnet ef` can build the internal context without a host.</summary>
|
||
|
|
internal sealed class GovernanceDbContextFactory : IDesignTimeDbContextFactory<GovernanceDbContext>
|
||
|
|
{
|
||
|
|
public GovernanceDbContext CreateDbContext(string[] args)
|
||
|
|
{
|
||
|
|
var connectionString =
|
||
|
|
Environment.GetEnvironmentVariable("ConnectionStrings__Postgres")
|
||
|
|
?? "Host=localhost;Port=5432;Database=teamup;Username=teamup;Password=teamup";
|
||
|
|
|
||
|
|
var options = new DbContextOptionsBuilder<GovernanceDbContext>()
|
||
|
|
.UseNpgsql(connectionString)
|
||
|
|
.Options;
|
||
|
|
|
||
|
|
return new GovernanceDbContext(options);
|
||
|
|
}
|
||
|
|
}
|