features/cutover-to-ef #9

Merged
jtom38 merged 27 commits from features/cutover-to-ef into main 2023-06-25 21:15:58 -07:00
2 changed files with 14 additions and 2 deletions
Showing only changes of commit aa5296d084 - Show all commits

View File

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

View File

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