From 98e17766b203734a1817eed94338e2d25f4395f7 Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 13 Feb 2021 16:20:18 +0200 Subject: Project Restructure P.1 --- src/Data/DevHive.Data/DevHiveContextFactory.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Data/DevHive.Data/DevHiveContextFactory.cs (limited to 'src/Data/DevHive.Data/DevHiveContextFactory.cs') diff --git a/src/Data/DevHive.Data/DevHiveContextFactory.cs b/src/Data/DevHive.Data/DevHiveContextFactory.cs new file mode 100644 index 0000000..f4849d7 --- /dev/null +++ b/src/Data/DevHive.Data/DevHiveContextFactory.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; +using System.IO; + +namespace DevHive.Data +{ + public class DevHiveContextFactory : IDesignTimeDbContextFactory + { + public DevHiveContext CreateDbContext(string[] args) + { + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("ConnectionString.json") + .Build(); + + var optionsBuilder = new DbContextOptionsBuilder() + .UseNpgsql(configuration.GetConnectionString("DEV")); + + return new DevHiveContext(optionsBuilder.Options); + } + } +} \ No newline at end of file -- cgit v1.2.3