AspireSqlServerSqlClientExtensions Methods
Class Methods 2 members
Extension methods for configuring SqlClient connection to Azure SQL, MS SQL server
AddKeyedSqlServerClient(IHostApplicationBuilder, string, Action<MicrosoftDataSqlClientSettings>) Section titled AddKeyedSqlServerClient(IHostApplicationBuilder, string, Action<MicrosoftDataSqlClientSettings>) extension Registers 'Scoped'
SqlClient.SqlConnection factory for given name for connecting Azure SQL, MsSQL database using Microsoft.Data.SqlClient. Configures health check, logging and telemetry for the SqlClient. public static class AspireSqlServerSqlClientExtensions{ public static void AddKeyedSqlServerClient( this IHostApplicationBuilder builder, string name, Action<MicrosoftDataSqlClientSettings>? configureSettings = null) { // ... }}Parameters
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to. name string The name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section. configureSettings Action<MicrosoftDataSqlClientSettings> optional An optional method that can be used for customizing options. It's invoked after the settings are read from the configuration. Exceptions
InvalidOperationException If required MicrosoftDataSqlClientSettings.ConnectionString is not provided in configuration section. Remarks
Reads the configuration from "Aspire:Microsoft:Data:SqlClient:{name}" section.
AddSqlServerClient(IHostApplicationBuilder, string, Action<MicrosoftDataSqlClientSettings>) Section titled AddSqlServerClient(IHostApplicationBuilder, string, Action<MicrosoftDataSqlClientSettings>) extension Registers 'Scoped'
SqlClient.SqlConnection factory for connecting Azure SQL, MS SQL database using Microsoft.Data.SqlClient. Configures health check, logging and telemetry for the SqlClient. public static class AspireSqlServerSqlClientExtensions{ public static void AddSqlServerClient( this IHostApplicationBuilder builder, string connectionName, Action<MicrosoftDataSqlClientSettings>? configureSettings = null) { // ... }}Parameters
builder IHostApplicationBuilder The Hosting.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<MicrosoftDataSqlClientSettings> optional An optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration. Exceptions
InvalidOperationException If required MicrosoftDataSqlClientSettings.ConnectionString is not provided in configuration section. Remarks
Reads the configuration from "Aspire:Microsoft:Data:SqlClient" section.