classlib/ExpenseTracker.Persistence/PostgreSQL/ApplicationDbContext.cs
2024-08-07 21:12:02 +03:00

27 lines
790 B
C#

using System.Reflection;
using Microsoft.EntityFrameworkCore;
using ExpenseTracker.Domain.Entities;
namespace ExpenseTracker.Persistence.PostgreSQL;
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
public DbSet<Transaction> Expenses { get => Set<Transaction>(); }
public DbSet<Account> Budgets { get => Set<Account>(); }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.HasDefaultSchema("domain");
builder.ApplyConfigurationsFromAssembly(
Assembly.GetExecutingAssembly(),
t => t.Namespace == "ExpenseTracker.Persistence.PostgreSQL.Configurations"
);
}
}