Share via


AspireOracleEFCoreExtensions.AddOracleDatabaseDbContext<TContext> Method

Definition

Registers the given DbContext as a service in the services provided by the builder. Enables db context pooling, retries, health check, logging and telemetry for the DbContext.

public static void AddOracleDatabaseDbContext<TContext> (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, Action<Aspire.Oracle.EntityFrameworkCore.OracleEntityFrameworkCoreSettings>? configureSettings = default, Action<Microsoft.EntityFrameworkCore.DbContextOptionsBuilder>? configureDbContextOptions = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
static member AddOracleDatabaseDbContext : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Oracle.EntityFrameworkCore.OracleEntityFrameworkCoreSettings> * Action<Microsoft.EntityFrameworkCore.DbContextOptionsBuilder> -> unit (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
<Extension()>
Public Sub AddOracleDatabaseDbContext(Of TContext As DbContext) (builder As IHostApplicationBuilder, connectionName As String, Optional configureSettings As Action(Of OracleEntityFrameworkCoreSettings) = Nothing, Optional configureDbContextOptions As Action(Of DbContextOptionsBuilder) = Nothing)

Type Parameters

TContext

The DbContext that needs to be registered.

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to read config from and add services to.

connectionName
String

A name used to retrieve the connection string from the ConnectionStrings configuration section.

configureSettings
Action<OracleEntityFrameworkCoreSettings>

An optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.

configureDbContextOptions
Action<DbContextOptionsBuilder>

An optional delegate to configure the DbContextOptions for the context.

Exceptions

Thrown if mandatory builder is null.

Thrown when mandatory ConnectionString is not provided.

Remarks

Reads the configuration from "Aspire:Oracle:EntityFrameworkCore:{typeof(TContext).Name}" config section, or "Aspire:Oracle:EntityFrameworkCore" if former does not exist.

Applies to