fengling-platform/Fengling.Platform.Infrastructure/DesignTimeApplicationDbContextFactory.cs
movingsam d737688e9b feat(auth): extract Tenant to Platform domain
- Add Fengling.Platform domain and infrastructure projects
- Move Tenant aggregate from AuthService/Console to Platform.Domain
- Add TenantRepository and SeedData to Platform
- Remove duplicate Tenant/TenantInfo models from AuthService and Console
- Update controllers and services to use Platform.Domain.Tenant
- Add new migrations for PlatformDbContext

BREAKING CHANGE: Tenant entity now uses strongly-typed ID (TenantId)
2026-02-18 23:02:03 +08:00

27 lines
1.1 KiB
C#

namespace Fengling.Platform.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.DependencyInjection;
public class DesignTimeApplicationDbContextFactory : IDesignTimeDbContextFactory<PlatformDbContext>
{
public PlatformDbContext CreateDbContext(string[] args)
{
IServiceCollection services = new ServiceCollection();
services.AddMediatR(c =>
c.RegisterServicesFromAssemblies(typeof(DesignTimeApplicationDbContextFactory).Assembly));
services.AddDbContext<PlatformDbContext>(options =>
{
options.UseNpgsql("Host=localhost;Database=fengling_platform;Username=postgres;Password=postgres",
b =>
{
b.MigrationsAssembly(typeof(DesignTimeApplicationDbContextFactory).Assembly.FullName);
});
});
var provider = services.BuildServiceProvider();
var dbContext = provider.CreateScope().ServiceProvider.GetRequiredService<PlatformDbContext>();
return dbContext;
}
}