20 lines
763 B
C#
20 lines
763 B
C#
namespace LiteCharms.Infrastructure.Database;
|
|
|
|
public class LeadGeneratorDbContextFactory : IDesignTimeDbContextFactory<LeadGeneratorDbContext>
|
|
{
|
|
public LeadGeneratorDbContext CreateDbContext(string[] args)
|
|
{
|
|
var configuration = new ConfigurationBuilder()
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
.AddUserSecrets(typeof(LeadGeneratorDbContext).Assembly)
|
|
.AddJsonFile("appsettings.json")
|
|
.AddEnvironmentVariables()
|
|
.Build();
|
|
|
|
var optionsBuilder = new DbContextOptionsBuilder<LeadGeneratorDbContext>();
|
|
optionsBuilder.UseNpgsql(configuration.GetConnectionString("PostgresLeadGenerator"));
|
|
|
|
return new LeadGeneratorDbContext(optionsBuilder.Options);
|
|
}
|
|
}
|