Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

Connection string is missing

Feedback

In this article

In 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.

Symptoms

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."

Possible solutions

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 namedb1 like this:

var db1 = builder.AddPostgres("pg1").AddDatabase("db1");

Then the service needs to resolve the resource with the same namedb1.

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.

Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, seeour contributor guide.

Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?