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