38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Design;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SewerStammGen.EntityFramework
|
|
{
|
|
public class SewerStammGenDbContextFactory : IDesignTimeDbContextFactory<SewerStammGenDbContext>
|
|
{
|
|
private readonly Action<DbContextOptionsBuilder> _configureDbContext;
|
|
|
|
public SewerStammGenDbContextFactory() { }
|
|
|
|
public SewerStammGenDbContextFactory(Action<DbContextOptionsBuilder> configureDbContext)
|
|
{
|
|
_configureDbContext = configureDbContext;
|
|
}
|
|
|
|
public SewerStammGenDbContext CreateDbContext()
|
|
{
|
|
DbContextOptionsBuilder<SewerStammGenDbContext>? options = new();
|
|
_configureDbContext( options );
|
|
return new SewerStammGenDbContext(options.Options);
|
|
}
|
|
|
|
public SewerStammGenDbContext CreateDbContext(string[] args)
|
|
{
|
|
var options = new DbContextOptionsBuilder<SewerStammGenDbContext>();
|
|
options.UseNpgsql("Host = localhost; Database = SewerGen; Username = SewerGen; Password = SewerGen");
|
|
SewerStammGenDbContext result = new(options.Options);
|
|
return result;
|
|
}
|
|
}
|
|
}
|