Entityframework hinzugefügt

This commit is contained in:
2023-03-28 09:20:45 +02:00
parent 5b2ed72fe3
commit a1f5b8437c
18 changed files with 910 additions and 8 deletions

View File

@@ -0,0 +1,37 @@
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;
}
}
}