Files
TimetableDesigner.Backend.S…/TimetableDesigner.Backend.Services.Authentication.Database/DatabaseContext.cs

29 lines
1.0 KiB
C#
Raw Normal View History

2025-09-24 19:36:28 +02:00
using System.Reflection;
using Microsoft.EntityFrameworkCore;
2026-01-29 00:21:23 +01:00
using TimetableDesigner.Backend.Events.OutboxPattern;
2026-01-11 02:30:08 +01:00
using TimetableDesigner.Backend.Services.Authentication.Database.Model;
2025-09-24 19:36:28 +02:00
2026-01-11 02:30:08 +01:00
namespace TimetableDesigner.Backend.Services.Authentication.Database;
2025-09-24 19:36:28 +02:00
2026-01-29 00:21:23 +01:00
public class DatabaseContext : DbContext, IEventOutboxDbContext
2025-09-24 19:36:28 +02:00
{
public virtual DbSet<Account> Accounts { get; set; }
public virtual DbSet<RefreshToken> RefreshTokens { get; set; }
2026-01-29 00:21:23 +01:00
public virtual DbSet<Event> Events { get; set; }
2025-09-24 19:36:28 +02:00
public DatabaseContext() { }
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) =>
optionsBuilder.UseNpgsql("name=Database");
2026-01-29 00:21:23 +01:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
2025-09-24 19:36:28 +02:00
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetAssembly(typeof(DatabaseContext))!);
2026-01-29 00:21:23 +01:00
modelBuilder.ApplyConfiguration(new EventConfiguration());
}
2025-09-24 19:36:28 +02:00
}