AspireSqlServerSqlClientExtensions.AddKeyedSqlServerClient Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers 'Scoped' 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 void AddKeyedSqlServerClient (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string name, Action<Aspire.Microsoft.Data.SqlClient.MicrosoftDataSqlClientSettings>? configureSettings = default);
static member AddKeyedSqlServerClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Microsoft.Data.SqlClient.MicrosoftDataSqlClientSettings> -> unit
<Extension()>
Public Sub AddKeyedSqlServerClient (builder As IHostApplicationBuilder, name As String, Optional configureSettings As Action(Of MicrosoftDataSqlClientSettings) = Nothing)
Parameters
- builder
- IHostApplicationBuilder
The IHostApplicationBuilder to read config from and add services to.
- name
- String
The name of the component, which is used as the ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
- configureSettings
- Action<MicrosoftDataSqlClientSettings>
An optional method that can be used for customizing options. It's invoked after the settings are read from the configuration.
Exceptions
If required ConnectionString is not provided in configuration section.
Remarks
Reads the configuration from "Aspire:Microsoft:Data:SqlClient:{name}" section.