2023-10-12 07:15:34 +00:00
|
|
|
namespace Server.DB;
|
2023-08-10 08:47:35 +00:00
|
|
|
|
2023-08-12 21:02:59 +00:00
|
|
|
using Documents;
|
2023-08-14 11:49:27 +00:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2023-08-10 08:47:35 +00:00
|
|
|
|
2023-08-14 11:49:27 +00:00
|
|
|
public class WonderkingContext : DbContext
|
2023-08-10 08:47:35 +00:00
|
|
|
{
|
2023-10-27 17:47:17 +00:00
|
|
|
private readonly IConfiguration _configuration;
|
|
|
|
private readonly ILoggerFactory _loggerFactory;
|
2023-08-14 11:49:27 +00:00
|
|
|
|
|
|
|
public WonderkingContext(ILoggerFactory loggerFactory, IConfiguration configuration)
|
2023-08-10 08:47:35 +00:00
|
|
|
{
|
2023-10-27 17:47:17 +00:00
|
|
|
this._loggerFactory = loggerFactory;
|
|
|
|
this._configuration = configuration;
|
2023-08-10 08:47:35 +00:00
|
|
|
}
|
2023-08-12 21:02:59 +00:00
|
|
|
|
2023-08-14 19:30:32 +00:00
|
|
|
public DbSet<Account> Accounts { get; set; }
|
2023-08-14 20:30:35 +00:00
|
|
|
public DbSet<Character> Characters { get; set; }
|
2023-08-14 19:30:32 +00:00
|
|
|
|
2023-08-14 11:49:27 +00:00
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) =>
|
|
|
|
optionsBuilder
|
|
|
|
.UseNpgsql(
|
2023-10-27 17:47:17 +00:00
|
|
|
$"Host={this._configuration["DB:Host"]};Username={this._configuration["DB:Username"]};Password={this._configuration["DB:Password"]};Database={this._configuration["DB:Database"]};Port={this._configuration["DB:Port"]}")
|
|
|
|
.EnableSensitiveDataLogging().UseLoggerFactory(this._loggerFactory);
|
2023-08-11 09:31:30 +00:00
|
|
|
}
|