LinkMenuExpand(external link)DocumentSearchCopyCopied

MySqlConnection.ProvidePasswordCallback property

Gets or sets the delegate used to generate a password for new database connections.

public Func<MySqlProvidePasswordContext, string>? ProvidePasswordCallback { get; set; }

Remarks

This delegate is executed when a new database connection is opened that requires a password. Due to connection pooling, this delegate is only executed when a new physical connection is established with a database server, not when a connection is retrieved from the pool.

The Password option takes precedence over this delegate if it is specified.

Using this delegate can make more efficient use of connection pooling for servers that require frequently-changing passwords or authentication tokens. Changing the password in the connection string will create unique connection pools; this delegate allows a single connection pool to use multiple passwords.

See Also