Skip to content

How to Aspire with AddPooledDbContextFactory #2752

Answered by sebastienros
jkears asked this question in Q&A
Discussion options

You must be logged in to vote

A new API has been added since this question was asked. You can now configure the DB context by yourself using EnrichSqlServerDbContext. See https://github.com/dotnet/aspire/blob/main/src/Components/Aspire.Microsoft.EntityFrameworkCore.SqlServer/README.md#usage-example

var connectionString = builder.Configuration.GetConnectionString("catalogdb");
builder.Services.AddDbContextPool<CatalogDbContext>(dbContextOptionsBuilder => dbContextOptionsBuilder.UseSqlServer(connectionString));
builder.EnrichSqlServerDbContext<CatalogDbContext>();

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by davidfowl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #2544 on March 10, 2024 00:02.