feat(directory): throw if readonly context SaveChanges is called

This commit is contained in:
Collin M. Barrett 2020-08-22 17:41:01 -05:00
parent 5216d9577d
commit 3f83b6edf2

View file

@ -1,4 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using FilterLists.Directory.Infrastructure.Persistence.Queries.Entities;
using FilterLists.Directory.Infrastructure.Persistence.Queries.Mappings;
using Microsoft.EntityFrameworkCore;
@ -19,6 +21,16 @@ public DirectoryQueryDbContext(DbContextOptions<DirectoryQueryDbContext> options
public DbSet<Syntax> Syntaxes => Set<Syntax>();
public DbSet<Tag> Tags => Set<Tag>();
public override int SaveChanges(bool acceptAllChangesOnSuccess)
{
throw new InvalidOperationException("This context is read-only.");
}
public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = new CancellationToken())
{
throw new InvalidOperationException("This context is read-only.");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
_ = modelBuilder ?? throw new ArgumentNullException(nameof(modelBuilder));