Share via


MySqlBuilderExtensions.AddDatabase Method

Definition

Adds a MySQL database to the application model.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.MySqlDatabaseResource> AddDatabase(this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.MySqlServerResource> builder, string name, string? databaseName = default);
static member AddDatabase : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.MySqlServerResource> * string * string -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.MySqlDatabaseResource>
<Extension()>
Public Function AddDatabase (builder As IResourceBuilder(Of MySqlServerResource), name As String, Optional databaseName As String = Nothing) As IResourceBuilder(Of MySqlDatabaseResource)

Parameters

builder
IResourceBuilder<MySqlServerResource>

The MySQL server resource builder.

name
String

The name of the resource. This name will be used as the connection string name when referenced in a dependency.

databaseName
String

The name of the database. If not provided, this defaults to the same value as name.

Returns

A reference to the IResourceBuilder<T>.

Remarks

When adding a MySqlDatabaseResource to your application model the resource can then be referenced by other resources using the resource name. When the dependent resource is using the extension method WaitFor<T>(IResourceBuilder<T>, IResourceBuilder<IResource>) then the dependent resource will wait until the MySQL database is available.

Note that calling AddDatabase(IResourceBuilder<MySqlServerResource>, String, String) will result in the database being created on the MySQL server when the server becomes ready. The database creation happens automatically as part of the resource lifecycle.

Applies to