AspireSqlServerSqlClientExtensions.AddSqlServerClient 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 connecting Azure SQL, MS SQL database using Microsoft.Data.SqlClient. Configures health check, logging and telemetry for the SqlClient.
public static void AddSqlServerClient (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, Action<Aspire.Microsoft.Data.SqlClient.MicrosoftDataSqlClientSettings>? configureSettings = default);
static member AddSqlServerClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Microsoft.Data.SqlClient.MicrosoftDataSqlClientSettings> -> unit
<Extension()>
Public Sub AddSqlServerClient (builder As IHostApplicationBuilder, connectionName As String, Optional configureSettings As Action(Of MicrosoftDataSqlClientSettings) = Nothing)
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<MicrosoftDataSqlClientSettings>
An optional delegate 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" section.