AppDbContext.cs 1.2 KB

123456789101112131415161718192021222324252627282930
  1. using Application.Abstractions.Data;
  2. using Domain.Entities.Common;
  3. using Domain.Entities.Members;
  4. using Domain.Entities.Page;
  5. using Domain.Entities.Page.Banner;
  6. using Domain.Entities.Page.Faq;
  7. using Microsoft.EntityFrameworkCore;
  8. namespace Infrastructure.Persistence
  9. {
  10. public sealed class AppDbContext : DbContext, IAppDbContext
  11. {
  12. public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
  13. public DbSet<Config> Config { get; set; }
  14. public DbSet<Document> Document { get; set; } = null!;
  15. public DbSet<Popup> Popup { get; set; } = null!;
  16. public DbSet<FaqCategory> FaqCategory { get; set; } = null!;
  17. public DbSet<FaqItem> FaqItem { get; set; } = null!;
  18. public DbSet<BannerPosition> BannerPosition { get; set; } = null!;
  19. public DbSet<BannerItem> BannerItem { get; set; } = null!;
  20. public DbSet<MemberGrade> MemberGrade { get; set; } = null!;
  21. protected override void OnModelCreating(ModelBuilder modelBuilder)
  22. {
  23. // Apply all configurations from the current assembly
  24. modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
  25. }
  26. }
  27. }