Context was updated to support identity
This commit is contained in:
parent
c25cafb0a7
commit
bfd185906c
@ -1,3 +1,5 @@
|
|||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newsbot.Collector.Domain.Consts;
|
using Newsbot.Collector.Domain.Consts;
|
||||||
@ -5,7 +7,7 @@ using Newsbot.Collector.Domain.Entities;
|
|||||||
|
|
||||||
namespace Newsbot.Collector.Database;
|
namespace Newsbot.Collector.Database;
|
||||||
|
|
||||||
public class DatabaseContext : DbContext
|
public class DatabaseContext : IdentityDbContext
|
||||||
{
|
{
|
||||||
public DbSet<ArticlesEntity> Articles { get; set; } = null!;
|
public DbSet<ArticlesEntity> Articles { get; set; } = null!;
|
||||||
public DbSet<DiscordQueueEntity> DiscordQueue { get; set; } = null!;
|
public DbSet<DiscordQueueEntity> DiscordQueue { get; set; } = null!;
|
||||||
@ -14,37 +16,50 @@ public class DatabaseContext : DbContext
|
|||||||
public DbSet<SourceEntity> Sources { get; set; } = null!;
|
public DbSet<SourceEntity> Sources { get; set; } = null!;
|
||||||
public DbSet<SubscriptionEntity> Subscriptions { get; set; } = null!;
|
public DbSet<SubscriptionEntity> Subscriptions { get; set; } = null!;
|
||||||
|
|
||||||
private string ConnectionString { get; set; }
|
//public DbSet<UserEntity> Users { get; set; } = null!;
|
||||||
|
|
||||||
public DatabaseContext(IConfiguration appsettings, string connectionString)
|
private string ConnectionString { get; set; } = "";
|
||||||
{
|
|
||||||
var connString = appsettings.GetConnectionString(ConfigConnectionStringConst.Database);
|
//public DatabaseContext(IConfiguration appsettings, string connectionString)
|
||||||
ConnectionString = connString ?? "";
|
//{
|
||||||
}
|
// var connString = appsettings.GetConnectionString(ConfigConnectionStringConst.Database);
|
||||||
|
// ConnectionString = connString ?? "";
|
||||||
|
//}
|
||||||
|
|
||||||
public DatabaseContext(string connectionString)
|
public DatabaseContext(string connectionString)
|
||||||
{
|
{
|
||||||
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);
|
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)
|
public DatabaseContext(DbContextOptions<DatabaseContext> options, string connectionString)
|
||||||
: base(options)
|
: base(options)
|
||||||
{
|
{
|
||||||
ConnectionString = connectionString;
|
//ConnectionString = connectionString;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="dapper" Version="2.0.123" />
|
<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" Version="7.0.8" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
Loading…
Reference in New Issue
Block a user