using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace Codex.Dal;

/// <summary>
/// Factory for creating DbContext at design time (for migrations).
/// </summary>
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<CodexDbContext>
{
    public CodexDbContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<CodexDbContext>();

        // Use a default connection string for design-time operations
        // This will be replaced by the actual connection string at runtime from appsettings.json
        optionsBuilder.UseNpgsql("Host=localhost;Database=codex;Username=jean-philippe");

        return new CodexDbContext(optionsBuilder.Options);
    }
}
