liveBook · Manning

ConnectionStrings section

As explained in Building Distributed Applications that Work

A named section of .NET application settings that holds database connection strings.

For an existing database, the Aspire host can store its connection string under a named entry in the ConnectionStrings section of appsettings.json. The name passed to AddConnectionString must match that entry. section 3.1

"ConnectionStrings": {
    "database": "<a valid SQL database connection string>"
}

Example appsettings.json entry for the name database. section 3.1

Pass the registered resource as a reference to the services that need it. Aspire service discovery resolves the connection string, so those services need not store it in their own settings. section 3.1

How Building Distributed Applications that Work covers it

How deep it goes
Maps a named setting to AddConnectionString and service resolution, but defers internally hosted database lifetimes.
Examples
Uses a database entry and names SQL Server, Oracle, and MongoDB as possible existing systems.
What it assumes
Assumes an Aspire host with AppHost.cs and appsettings.json; does not explain database-specific connection-string setup.
What you can do after
Apply Aspire's AddConnectionString and pass its resource reference to services to resolve the configured database connection.
How it connects
Links .NET application settings, AddConnectionString, and Aspire service discovery.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Distributed Applications that Work. The section links point to the parts of the book it draws on.