Migration to EF and starting to add Identity #11
@ -1,3 +1,5 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newsbot.Collector.Domain.Consts;
|
||||
@ -5,7 +7,7 @@ using Newsbot.Collector.Domain.Entities;
|
||||
|
||||
namespace Newsbot.Collector.Database;
|
||||
|
||||
public class DatabaseContext : DbContext
|
||||
public class DatabaseContext : IdentityDbContext
|
||||
{
|
||||
public DbSet<ArticlesEntity> Articles { get; set; } = null!;
|
||||
public DbSet<DiscordQueueEntity> DiscordQueue { get; set; } = null!;
|
||||
@ -13,38 +15,51 @@ public class DatabaseContext : DbContext
|
||||
public DbSet<IconEntity> Icons { get; set; } = null!;
|
||||
public DbSet<SourceEntity> Sources { get; set; } = null!;
|
||||
public DbSet<SubscriptionEntity> Subscriptions { get; set; } = null!;
|
||||
|
||||
private string ConnectionString { get; set; }
|
||||
|
||||
public DatabaseContext(IConfiguration appsettings, string connectionString)
|
||||
{
|
||||
var connString = appsettings.GetConnectionString(ConfigConnectionStringConst.Database);
|
||||
ConnectionString = connString ?? "";
|
||||
}
|
||||
//public DbSet<UserEntity> Users { get; set; } = null!;
|
||||
|
||||
private string ConnectionString { get; set; } = "";
|
||||
|
||||
//public DatabaseContext(IConfiguration appsettings, string connectionString)
|
||||
//{
|
||||
// var connString = appsettings.GetConnectionString(ConfigConnectionStringConst.Database);
|
||||
// ConnectionString = connString ?? "";
|
||||
//}
|
||||
|
||||
public DatabaseContext(string connectionString)
|
||||
{
|
||||
ConnectionString = connectionString;
|
||||
}
|
||||
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> connectionString)
|
||||
{
|
||||
ConnectionString = "";
|
||||
}
|
||||
|
||||
public DatabaseContext()
|
||||
{
|
||||
ConnectionString = "";
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
{
|
||||
options.UseNpgsql(ConnectionString);
|
||||
if (ConnectionString != "")
|
||||
{
|
||||
options.UseNpgsql(ConnectionString);
|
||||
}
|
||||
}
|
||||
|
||||
//public DatabaseContext(DbContextOptions<DatabaseContext> connectionString)
|
||||
//{
|
||||
// ConnectionString = "";
|
||||
//}
|
||||
|
||||
//public DatabaseContext()
|
||||
//{
|
||||
// ConnectionString = "";
|
||||
//}
|
||||
|
||||
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> options)
|
||||
: base(options)
|
||||
{
|
||||
//ConnectionString = "";
|
||||
|
||||
}
|
||||
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> options, string connectionString)
|
||||
: base(options)
|
||||
{
|
||||
ConnectionString = connectionString;
|
||||
//ConnectionString = connectionString;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="dapper" Version="2.0.123" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
Loading…
Reference in New Issue
Block a user