blob: dff2e9eefe1b4a87ae0c34af0a748565398090d2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace ExamTemplate.Data
{
public class TemplateContextFactory : IDesignTimeDbContextFactory<TemplateContext>
{
public TemplateContext CreateDbContext(string[] args)
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory() + "/../Web/")
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build();
var optionsBuilder = new DbContextOptionsBuilder<TemplateContext>()
.UseNpgsql(configuration.GetConnectionString("LocalDBConnection"));
return new TemplateContext(optionsBuilder.Options);
}
}
}
|