using LifePayment.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore.Design;
|
using Microsoft.Extensions.Configuration;
|
using System.IO;
|
using Volo.Abp.Identity.EntityFrameworkCore;
|
|
namespace LifePayment.Host
|
{
|
public class DesignFactory : IDesignTimeDbContextFactory<LifePaymentServicesDbContext>
|
{
|
public LifePaymentServicesDbContext CreateDbContext(string[] args)
|
{
|
var configuration = BuildHelper.BuildConfiguration();
|
var builder = new DbContextOptionsBuilder<LifePaymentServicesDbContext>()
|
.UseSqlServer(configuration.GetConnectionString("LifePaymentServices"),
|
b => b.MigrationsAssembly("LifePaymentService.Host"));
|
return new LifePaymentServicesDbContext(builder.Options);
|
}
|
}
|
|
public class IdentityDesignFactory : IDesignTimeDbContextFactory<IdentityDbContext>
|
{
|
public IdentityDbContext CreateDbContext(string[] args)
|
{
|
var configuration = BuildHelper.BuildConfiguration();
|
var builder = new DbContextOptionsBuilder<IdentityDbContext>()
|
.UseSqlServer(configuration.GetConnectionString("AbpIdentity"),
|
b => b.MigrationsAssembly("LifePaymentService.Host"));
|
return new IdentityDbContext(builder.Options);
|
}
|
}
|
|
public class BuildHelper
|
{
|
public static IConfigurationRoot BuildConfiguration()
|
{
|
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: false);
|
return builder.Build();
|
}
|
}
|
}
|