From 1f6962768de80cb2a017d53a1985899063d062dd Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 19 Dec 2020 16:19:29 +0200 Subject: Moved migrations to DevHive.Data --- src/DevHive.Data/DevHiveContextFactory.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/DevHive.Data/DevHiveContextFactory.cs (limited to 'src/DevHive.Data/DevHiveContextFactory.cs') diff --git a/src/DevHive.Data/DevHiveContextFactory.cs b/src/DevHive.Data/DevHiveContextFactory.cs new file mode 100644 index 0000000..f4849d7 --- /dev/null +++ b/src/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