Entityframework hinzugefügt
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user