Skip to content

Latest commit

 

History

History

README.md

Working with database containers in an Aspire application

This sample demonstrates working with database containers in an Aspire app, using the features of the underlying container image to modify the default database created during container startup. This is especially helpful when not using an ORM like Entity Framework Core that can run migrations on application startup (e.g., as in the Aspire Shop sample) and handle cases when the database configured in the AppHost is not yet created.

Screenshot of the Scalar API reference for the API service that returns data from the configured database containers

The app uses the following database container types:

The app consists of an API service:

  • ContainerDatabases.ApiService: This is an HTTP API that returns data from each of the configured databases.

Prerequisites

Running the app

If using the Aspire CLI, run aspire run from this directory.

If using VS Code, open this directory as a workspace and launch the DatabaseContainers.AppHost project using either the Aspire or C# debuggers.

If using Visual Studio, open the solution file DatabaseContainers.slnx and launch/debug the DatabaseContainers.AppHost project.

If using the .NET CLI, run dotnet run from the DatabaseContainers.AppHost directory.

From the Aspire dashboard, click on the endpoint URL for the DatabaseContainers.ApiService project to launch the Scalar API reference for the APIs. You can use the reference to explore and call the APIs and see the results.