using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DaSaSo.EntityFramework { public class DaSaSoDbContextFactory : IDesignTimeDbContextFactory { private readonly Action _configureDbContext; public DaSaSoDbContextFactory() { } public DaSaSoDbContextFactory(Action configureDbContext) { _configureDbContext = configureDbContext; } public DaSaSoDbContext CreateDbContext() { DbContextOptionsBuilder? options = new DbContextOptionsBuilder(); _configureDbContext(options); //_connectionString = "Host = localhost; Database = dasaso; Username = kansan; Password = kansan"; //options.UseNpgsql(_connectionString); //DaSaSoDbContext result = new DaSaSoDbContext(options.Options); return new DaSaSoDbContext(options.Options); } public DaSaSoDbContext CreateDbContext(string[] args) { var options = new DbContextOptionsBuilder(); options.UseNpgsql("Host = localhost; Database = dasaso; Username = kansan; Password = kansan"); DaSaSoDbContext result = new DaSaSoDbContext(options.Options); return result; } /* public DaSaSoDbContext CreateDbContext(string[]? args = null) { var options = new DbContextOptionsBuilder(); options.UseNpgsql("Host = localhost; Database = dasaso; Username = kansan; Password = kansan"); DaSaSoDbContext result = new DaSaSoDbContext(options.Options); return result; } */ } }