- 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)
27 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|