aboutsummaryrefslogtreecommitdiff
path: root/src/Costasdev.Busurbano.ServiceViewer/AppDbContextDesignTimeFactory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Costasdev.Busurbano.ServiceViewer/AppDbContextDesignTimeFactory.cs')
-rw-r--r--src/Costasdev.Busurbano.ServiceViewer/AppDbContextDesignTimeFactory.cs41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/Costasdev.Busurbano.ServiceViewer/AppDbContextDesignTimeFactory.cs b/src/Costasdev.Busurbano.ServiceViewer/AppDbContextDesignTimeFactory.cs
deleted file mode 100644
index 919c131..0000000
--- a/src/Costasdev.Busurbano.ServiceViewer/AppDbContextDesignTimeFactory.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using Costasdev.ServiceViewer.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Design;
-
-namespace Costasdev.ServiceViewer;
-
-public class AppDbContextDesignTimeFactory : IDesignTimeDbContextFactory<AppDbContext>
-{
- public AppDbContext CreateDbContext(string[] args)
- {
- IConfigurationRoot configuration = new ConfigurationBuilder()
- .AddJsonFile("appsettings.json", optional: true)
- .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json",
- optional: true)
- .AddUserSecrets(typeof(AppDbContext).Assembly, optional: true)
- .AddEnvironmentVariables()
- .Build();
-
- var builder = new DbContextOptionsBuilder<AppDbContext>();
- var connectionString = configuration.GetConnectionString("Database");
- if (string.IsNullOrEmpty(connectionString))
- {
- throw new InvalidOperationException("Connection string 'Database' not found.");
- }
-
- var loggerFactory = LoggerFactory.Create(lb =>
- {
- lb
- .AddConsole()
- .SetMinimumLevel(LogLevel.Information);
- });
- builder.UseLoggerFactory(loggerFactory);
-
- builder.UseNpgsql(
- connectionString,
- options => options.UseNetTopologySuite()
- );
-
- return new AppDbContext(builder.Options);
- }
-}