PostgresBuilderExtensions.AddDatabase 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.
Adds a PostgreSQL database to the application model.
public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresDatabaseResource> AddDatabase (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource> builder, string name, string? databaseName = default);
static member AddDatabase : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresServerResource> * string * string -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.PostgresDatabaseResource>
<Extension()>
Public Function AddDatabase (builder As IResourceBuilder(Of PostgresServerResource), name As String, Optional databaseName As String = Nothing) As IResourceBuilder(Of PostgresDatabaseResource)
Parameters
- builder
- IResourceBuilder<PostgresServerResource>
The PostgreSQL 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
This resource includes built-in health checks. When this resource is referenced as a dependency using the WaitFor<T>(IResourceBuilder<T>, IResourceBuilder<IResource>) extension method then the dependent resource will wait until the Postgres database is available.
Note that by default calling AddDatabase(IResourceBuilder<PostgresServerResource>, String, String) does not result in the database being created on the Postgres server. It is expected that code within your solution will create the database. As a result if WaitFor<T>(IResourceBuilder<T>, IResourceBuilder<IResource>) is used with this resource it will wait indefinitely until the database exists.