using System; using Microsoft.EntityFrameworkCore; using LCU.Library.Internal.DocumentIngestorModels.Entities; using Microsoft.EntityFrameworkCore.Query; namespace LCU.API.Internal.DocumentIngestorLib.Persistence; public class AppDbContext : DbContext { public DbSet IngestorRunInfos { get; set; } public DbSet DocumentProcessingInfos { get; set; } public DbSet ProcessingLogs { get; set; } public DbSet DocumentTypeArchiveDeleteInfos { get; set; } public DbSet OwnerOverrideInfos { get; set; } public DbSet PdfPartitionerRunInfos { get; set; } public DbSet PdfPartitionerLogs { get; set; } public DbSet MemberNotificationInfos { get; set; } public DbSet OsgPreprocessorInfos { get; set; } [DbFunction(nameof(JSON_VALUE), IsBuiltIn = true)] public static string JSON_VALUE(string column, [NotParameterized] string path) => throw new InvalidOperationException(); public AppDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity().ToTable("IngestorRunInfo"); builder.Entity().ToTable("DocumentProcessingInfo") .HasMany(x => x.MemberNotificationInfos) .WithOne() .HasForeignKey(x => x.DocumentProcessingInfoId) .IsRequired(false) .OnDelete(DeleteBehavior.Cascade); builder.Entity().ToTable("ProcessingLog"); builder.Entity().ToTable("DocumentTypeArchiveDeleteInfo"); builder.Entity().HasKey(d => d.DocumentTypeName); builder.Entity().ToTable("OwnerOverrideInfo"); builder.Entity().ToTable("PdfPartitionerRunInfo"); builder.Entity().ToTable("PdfPartitionerLog"); builder.Entity().ToTable("MemberNotificationInfo"); builder.Entity().ToTable("OsgPreprocessorInfo"); } }