using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Npgsql;
using DD.Persistence.Database.Model;
namespace DD.Persistence.Database.Postgres;
///
/// Фабрика контекста для dotnet ef миграций
///
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory
{
public PersistencePostgresContext CreateDbContext(string[] args)
{
var connectionStringBuilder = new NpgsqlConnectionStringBuilder
{
Host = "localhost",
Database = "persistence",
Username = "postgres",
Password = "q",
PersistSecurityInfo = true
};
var connectionString = connectionStringBuilder.ToString();
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseNpgsql(connectionString);
var context = new PersistencePostgresContext(optionsBuilder.Options);
return context;
}
}