24 lines
898 B
C#
24 lines
898 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Design;
|
|
|
|
namespace DeepDrftWeb.Data;
|
|
|
|
public static class DeepDrftContextFactory
|
|
{
|
|
public class Factory : IDesignTimeDbContextFactory<DeepDrftContext>
|
|
{
|
|
public DeepDrftContext CreateDbContext(string[] args)
|
|
{
|
|
var configuration = new ConfigurationBuilder()
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
|
.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true)
|
|
.Build();
|
|
|
|
var optionsBuilder = new DbContextOptionsBuilder<DeepDrftContext>();
|
|
optionsBuilder.UseSqlite(configuration.GetConnectionString("DefaultConnection"));
|
|
|
|
return new DeepDrftContext(optionsBuilder.Options);
|
|
}
|
|
}
|
|
} |