Skip to content
Discussion options

You must be logged in to vote

Or is there a way to use the connectionName defined in the AppHost project?

connectionName: "x" translates to builder.Configuration.GetConnectionString("x") so it should be trivial to do the same in your code:

builder.Services.AddDbContext<CatalogDbContext>((sp, options) =>
{
    options.AddInterceptors(sp.GetServices<ISaveChangesInterceptor>());
    options.UseNpgsql(builder.Configuration.GetConnectionString("x")); // Should we add the connection string?
});
builder.EnrichNpgsqlDbContext<CatalogDbContext>();

I see the confusion here, our documentation is wrong https://learn.microsoft.com/en-us/dotnet/aspire/database/postgresql-entity-framework-integration?tabs=dotnet-cli#add-npgsql-dat…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mehmetozkaya
Comment options

@davidfowl
Comment options

Answer selected by mehmetozkaya
@mehmetozkaya
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants