Table of Contents

Class NextOrmDbContextExtensions

Namespace
NextORM.EntityFrameworkCore
Assembly
nextorm.entityframeworkcore.dll

Registers the EF Core-to-nextorm bridge on DbContextOptionsBuilder and resolves a nextorm IDataContext from a DbContext or the DI container.

public static class NextOrmDbContextExtensions
Inheritance
NextOrmDbContextExtensions
Inherited Members

Remarks

The bridge never owns the EF connection or transaction: it borrows both and leaves EF in control, so disposing an IDataContext resolved through these methods does not close or dispose the DbContext.

Methods

AddNextOrmFromDbContext<TDbContext>(IServiceCollection, Action<DataContextBuilder>?)

Registers a scoped IDataContext that is built from the scope's TDbContext via GetNextOrmContext(DbContext).

public static IServiceCollection AddNextOrmFromDbContext<TDbContext>(this IServiceCollection services, Action<DataContextBuilder>? configure = null) where TDbContext : DbContext

Parameters

services IServiceCollection

The service collection to register into.

configure Action<DataContextBuilder>

Optional nextorm configuration applied after any delegate stored by UseNextOrm(DbContextOptionsBuilder, Action<DataContextBuilder>?).

Returns

IServiceCollection

The same services for chaining.

Type Parameters

TDbContext

The EF Core context type already registered in the container.

Exceptions

ArgumentNullException

services is null.

GetNextOrmContext(DbContext)

Creates a nextorm IDataContext over dbContext's connection, current transaction and model, applying the configuration stored by UseNextOrm(DbContextOptionsBuilder, Action<DataContextBuilder>?) when the context's options carry it.

public static IDataContext GetNextOrmContext(this DbContext dbContext)

Parameters

dbContext DbContext

The EF Core context whose connection, model and current transaction are reused.

Returns

IDataContext

An IDataContext that executes on the EF connection and inside EF's current transaction when one is active.

Exceptions

ArgumentNullException

dbContext is null.

InvalidOperationException

The EF provider reported by ProviderName is not one of the supported providers.

UseNextOrm(DbContextOptionsBuilder, Action<DataContextBuilder>?)

Stores the optional nextorm configuration on optionsBuilder, so that GetNextOrmContext(DbContext) can build a context without taking the delegate again.

public static DbContextOptionsBuilder UseNextOrm(this DbContextOptionsBuilder optionsBuilder, Action<DataContextBuilder>? configure = null)

Parameters

optionsBuilder DbContextOptionsBuilder

The EF Core options builder to extend.

configure Action<DataContextBuilder>

Optional nextorm configuration applied after the provider is selected.

Returns

DbContextOptionsBuilder

The same optionsBuilder for chaining.

Exceptions

ArgumentNullException

optionsBuilder is null.

UseNextOrm<TContext>(DbContextOptionsBuilder<TContext>, Action<DataContextBuilder>?)

Stores the optional nextorm configuration on the strongly typed optionsBuilder, so that GetNextOrmContext(DbContext) can build a context without taking the delegate again.

public static DbContextOptionsBuilder<TContext> UseNextOrm<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, Action<DataContextBuilder>? configure = null) where TContext : DbContext

Parameters

optionsBuilder DbContextOptionsBuilder<TContext>

The EF Core options builder to extend.

configure Action<DataContextBuilder>

Optional nextorm configuration applied after the provider is selected.

Returns

DbContextOptionsBuilder<TContext>

The same optionsBuilder for chaining.

Type Parameters

TContext

The EF Core context type the options belong to.

Exceptions

ArgumentNullException

optionsBuilder is null.