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) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.namestringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettings Action<SqliteEntityFrameworkCoreSettings> optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.configureDbContextOptions Action<DbContextOptionsBuilder> optionalAn optional method that can be used for customizing the EntityFrameworkCore.DbContextOptionsBuilder`1 .Exceptions
ArgumentNullExceptionThrown if mandatory builder is null.InvalidOperationExceptionThrown when mandatory SqliteEntityFrameworkCoreSettings.ConnectionString is not provided.Remarks
Reads the configuration from "Aspire:Sqlite:EntityFrameworkCore:Sqlite:{typeof(TContext).Name}" config section, or "Aspire:Sqlite:EntityFrameworkCore:Sqlite" if former does not exist.
The Db method can then be overridden to configure Entity 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) { // ... }}Parameters
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.configureSettings Action<SqliteEntityFrameworkCoreSettings> optionalAn optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.Exceptions
ArgumentNullExceptionThrown if mandatory builder is null.InvalidOperationExceptionThrown when mandatory EntityFrameworkCore.DbContext is not registered in DI.