How to Aspire with AddPooledDbContextFactory #2752
-
I have an existing downstream service that connects to EF Core SQL as per this configuration method that is called from it's program.cs startup and I am using KeyVault to obtain the SQL Connection string ...
As can be seen, I am utilizing Pooled DB Context Factory via In the service project I replaced the existing EntityFrameworkCore with this package reference ...
As I can't seem to call AddPooledDbContextFactory to set settings as per the following; 'Tracing = true', ... I instead added the following configuration within the service project as follows ...
While this runs as it did prior to Aspire, I do not see any tracing wrt calls made against the AppDbContext. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Same basic question, trying to call |
Beta Was this translation helpful? Give feedback.
-
A new API has been added since this question was asked. You can now configure the DB context by yourself using var connectionString = builder.Configuration.GetConnectionString("catalogdb");
builder.Services.AddDbContextPool<CatalogDbContext>(dbContextOptionsBuilder => dbContextOptionsBuilder.UseSqlServer(connectionString));
builder.EnrichSqlServerDbContext<CatalogDbContext>(); |
Beta Was this translation helpful? Give feedback.
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