Udostępnij za pośrednictwem


AspireMySqlConnectorExtensions.AddMySqlDataSource Method

Definition

Registers MySqlConnector.MySqlDataSource service for connecting MySQL database with MySqlConnector client. Configures health check, logging and telemetry for the MySqlConnector client.

public static void AddMySqlDataSource (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, Action<Aspire.MySqlConnector.MySqlConnectorSettings>? configureSettings = default);
static member AddMySqlDataSource : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.MySqlConnector.MySqlConnectorSettings> -> unit
<Extension()>
Public Sub AddMySqlDataSource (builder As IHostApplicationBuilder, connectionName As String, Optional configureSettings As Action(Of MySqlConnectorSettings) = 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<MySqlConnectorSettings>

An optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.

Exceptions

Thrown if mandatory builder is null.

Thrown when mandatory ConnectionString is not provided.

Remarks

Reads the configuration from "Aspire:MySqlConnector" section.

Applies to