chore: init project
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace InboxIntel.Infrastructure.Persistence;
|
||||
|
||||
/// <summary>
|
||||
/// Design-time factory so `dotnet ef migrations add ...` works without booting
|
||||
/// the full API host. Reads the connection string from the EF_CONNECTION env
|
||||
/// var, falling back to a local default.
|
||||
/// </summary>
|
||||
public class AppDbContextFactory : IDesignTimeDbContextFactory<AppDbContext>
|
||||
{
|
||||
public AppDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var conn = Environment.GetEnvironmentVariable("EF_CONNECTION")
|
||||
?? "Host=localhost;Port=5432;Database=inboxintel;Username=inboxintel;Password=inboxintel";
|
||||
var options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseNpgsql(conn)
|
||||
.Options;
|
||||
return new AppDbContext(options);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user