Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In .NET Aspire, code identifies resources with an arbitrary string, such as "database". Code that is consuming the resource elsewhere must use the same string or it will fail to correctly configure their relationships.
When your app accesses a service that needs one of the integrations in your app, it may fail with an exception similar to the following:
"InvalidOperationException: ConnectionString is missing."
Verify that the name of the resource, for instance a database resource, is the same in the AppHost and the Service that fails.
For example, if the AppHost defines a PostgreSQL resource with the name db1
like this:
var db1 = builder.AddPostgres("pg1").AddDatabase("db1");
Then the service needs to resolve the resource with the same name db1
.
var builder = WebApplication.CreateBuilder(args);
builder.AddNpgsqlDbContext<MyDb1Context>("db1");
Any other value than the one provided in the AppHost will result in the exception message described above.
.NET Aspire feedback
.NET Aspire is an open source project. Select a link to provide feedback:
Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Use databases in a .NET Aspire project - Training
Learn about the database systems that .NET Aspire can connect to using built-in integrations. Then see how to configure connections to, and store data in, relational and nonrelational databases.
Documentation
.NET Aspire SQL Server integration - .NET Aspire
Learn how to use the .NET Aspire SQL Server integration, which includes both hosting and client integrations.
.NET Aspire SQL Server Entity Framework Core integration - .NET Aspire
Learn how to use the .NET Aspire SQL Server Entity Framework integration, which includes both hosting and client integrations.
Seed data in a database using .NET Aspire - .NET Aspire
Learn about how to seed database data in .NET Aspire