Compartilhar via


MongoDBBuilderExtensions.AddDatabase Method

Definition

Adds a MongoDB database to the application model.

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

Parameters

builder
IResourceBuilder<MongoDBServerResource>

The MongoDB 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>.

Applies to