ef migrations was updated with the requirements of DesignTimeContext.cs

This commit is contained in:
James Tombleson 2023-06-25 21:04:31 -07:00
parent 4720c23915
commit aa5296d084
2 changed files with 14 additions and 2 deletions

View File

@ -16,7 +16,7 @@ public class DatabaseContext : DbContext
private string ConnectionString { get; set; }
public DatabaseContext(IConfiguration appsettings)
public DatabaseContext(IConfiguration appsettings, string connectionString)
{
var connString = appsettings.GetConnectionString(ConfigConnectionStringConst.Database);
ConnectionString = connString ?? "";
@ -27,13 +27,24 @@ public class DatabaseContext : DbContext
ConnectionString = connectionString;
}
public DatabaseContext(DbContextOptions<DatabaseContext> connectionString)
{
ConnectionString = "";
}
public DatabaseContext()
{
ConnectionString = "";
}
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
options.UseNpgsql(ConnectionString);
}
public DatabaseContext(DbContextOptions<DatabaseContext> options)
public DatabaseContext(DbContextOptions<DatabaseContext> options, string connectionString)
: base(options)
{
ConnectionString = connectionString;
}
}

View File

@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace Newsbot.Collector.Database;