Skip to main content
Table of Contents

Interface IDbContext

Namespace
Stratara.EventSourcing.EntityFrameworkCore.Abstractions
Assembly
Stratara.EventSourcing.EntityFrameworkCore.dll

Minimal DbContext surface that Stratara repositories program against, exposing the parts of DbContext needed for persistence without depending on the concrete EF Core type.

public interface IDbContext
Extension Methods

Remarks

Implemented by the Write, Read, and Identity DbContexts so that repositories and unit-of-work implementations can be constructor-injected without a hard coupling to a specific context type.

Properties

ChangeTracker

Gets the EF Core change tracker for the current context.

ChangeTracker ChangeTracker { get; }

Property Value

ChangeTracker

Database

Gets the database facade for migrations, transactions, and raw SQL.

DatabaseFacade Database { get; }

Property Value

DatabaseFacade

Methods

SaveChanges()

Persists all pending changes to the underlying database synchronously.

int SaveChanges()

Returns

int

The number of state entries written to the database.

SaveChangesAsync(CancellationToken)

Persists all pending changes to the underlying database asynchronously.

Task<int> SaveChangesAsync(CancellationToken token = default)

Parameters

token CancellationToken

Token used to cancel the save operation.

Returns

Task<int>

The number of state entries written to the database.

Set<TEntity>()

Returns a DbSet<TEntity> for the given entity type.

DbSet<TEntity> Set<TEntity>() where TEntity : class

Returns

DbSet<TEntity>

Type Parameters

TEntity

The entity type tracked by the context.