AspireEFSqliteExtensions Methods

ClassMethods2 members
Extension methods for configuring Sqlite with Entity Framework Core.
AddSqliteDbContext(IHostApplicationBuilder, string, Action<SqliteEntityFrameworkCoreSettings>, Action<DbContextOptionsBuilder>)Section titled AddSqliteDbContext(IHostApplicationBuilder, string, Action<SqliteEntityFrameworkCoreSettings>, Action<DbContextOptionsBuilder>)extension
Registers the TContext as a scoped service in the services provided by the builder.
public static class AspireEFSqliteExtensions
{
public static void AddSqliteDbContext<TContext>(
this IHostApplicationBuilder builder,
string name,
Action<SqliteEntityFrameworkCoreSettings>? configureSettings = null,
Action<DbContextOptionsBuilder>? configureDbContextOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringA name used to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<SqliteEntityFrameworkCoreSettings>optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.
configureDbContextOptionsAction<DbContextOptionsBuilder>optionalAn optional method that can be used for customizing the EntityFrameworkCore.DbContextOptionsBuilder`1.
ArgumentNullExceptionThrown if mandatory builder is null.
InvalidOperationExceptionThrown when mandatory SqliteEntityFrameworkCoreSettings.ConnectionString is not provided.

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

The DbContext.OnConfiguring method can then be overridden to configure EntityFrameworkCore.DbContext options.

EnrichSqliteDatabaseDbContext(IHostApplicationBuilder, Action<SqliteEntityFrameworkCoreSettings>)Section titled EnrichSqliteDatabaseDbContext(IHostApplicationBuilder, Action<SqliteEntityFrameworkCoreSettings>)extension
Configures retries, health check, logging and telemetry for the EntityFrameworkCore.DbContext.
public static class AspireEFSqliteExtensions
{
public static void EnrichSqliteDatabaseDbContext<TDbContext>(
this IHostApplicationBuilder builder,
Action<SqliteEntityFrameworkCoreSettings>? configureSettings = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
configureSettingsAction<SqliteEntityFrameworkCoreSettings>optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.
ArgumentNullExceptionThrown if mandatory builder is null.
InvalidOperationExceptionThrown when mandatory EntityFrameworkCore.DbContext is not registered in DI.