feat: add core persistence model
This commit is contained in:
22
Tiku.DbMigrator/DesignTimeTikuDbContextFactory.cs
Normal file
22
Tiku.DbMigrator/DesignTimeTikuDbContextFactory.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using Tiku.Infrastructure.Persistence;
|
||||
|
||||
namespace Tiku.DbMigrator;
|
||||
|
||||
public sealed class DesignTimeTikuDbContextFactory : IDesignTimeDbContextFactory<TikuDbContext>
|
||||
{
|
||||
public TikuDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var connectionString =
|
||||
Environment.GetEnvironmentVariable("DATABASE_URL") ??
|
||||
"Host=localhost;Database=tiku;Username=postgres";
|
||||
|
||||
var options = new DbContextOptionsBuilder<TikuDbContext>()
|
||||
.UseNpgsql(connectionString, npgsql =>
|
||||
npgsql.MigrationsAssembly(typeof(TikuDbContext).Assembly.FullName))
|
||||
.Options;
|
||||
|
||||
return new TikuDbContext(options);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user