using Microsoft.EntityFrameworkCore; using Prefab.Handler; namespace Prefab.Catalog.Api.Data; public class AppDbReadOnly(DbContextOptions options, IHandlerContextAccessor accessor) : AppDb(options, accessor), Prefab.Data.IPrefabDbReadOnly, Prefab.Catalog.Data.IModuleDbReadOnly { protected override void PrefabOnConfiguring(DbContextOptionsBuilder optionsBuilder) { base.PrefabOnConfiguring(optionsBuilder); optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); } public override int SaveChanges() => throw new InvalidOperationException("This database context is read-only. Saving changes is not allowed."); public override Task SaveChangesAsync(CancellationToken cancellationToken = default) => throw new InvalidOperationException("This database context is read-only. Saving changes is not allowed."); }