Docs
Tenantry CoreAPI reference

DbContextOptionsBuilderExtensions class

Namespace: Tenantry.EfCore.Extensions · Package: Tenantry.EfCore · API reference

Extension methods for wiring Tenantry into DbContextOptionsBuilder.

public static class DbContextOptionsBuilderExtensions

Methods

AddTenantInterceptors(DbContextOptionsBuilder, IServiceProvider)

Adds Tenantry interceptors to the DbContextOptionsBuilder. Requires AddEfCoreIsolation() to have been called inside AddTenantryCore().

public static DbContextOptionsBuilder AddTenantInterceptors(this DbContextOptionsBuilder optionsBuilder, IServiceProvider serviceProvider)

Parameters:

  • optionsBuilder DbContextOptionsBuilder: The options builder for the application's DbContext.
  • serviceProvider IServiceProvider: The IServiceProvider from the AddDbContext factory callback, used to resolve the interceptor singleton.

Returns: DbContextOptionsBuilder: The same optionsBuilder for chaining.

services.AddDbContext<AppDbContext>((sp, options) =>
    options.UseSqlServer(connectionString)
           .AddTenantInterceptors(sp));

On this page