Init
This commit is contained in:
20
Prefab.Web/Data/AppDbReadOnly.cs
Normal file
20
Prefab.Web/Data/AppDbReadOnly.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Prefab.Handler;
|
||||
|
||||
namespace Prefab.Web.Data;
|
||||
|
||||
public class AppDbReadOnly(DbContextOptions<AppDbReadOnly> 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<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
=> throw new InvalidOperationException("This database context is read-only. Saving changes is not allowed.");
|
||||
}
|
||||
Reference in New Issue
Block a user