Open uabarahona opened 1 month ago
@eerhardt PTAL
You can use any EF API to add your DbContext as normal, and then use the EnrichXDbContext
method to add the Aspire specific capabilities to it.
Take a look at
You might also need to configure specific option of Sql Server, or register a DbContext in other ways. In this case call the EnrichSqlServerDbContext extension method, for example:
var connectionString = builder.Configuration.GetConnectionString("catalogdb");
builder.Services.AddDbContextPool<CatalogDbContext>(dbContextOptionsBuilder => dbContextOptionsBuilder.UseSqlServer(connectionString));
builder.EnrichSqlServerDbContext<CatalogDbContext>();
@sebastienros @IEvangelist - I don't see any information about the Enrich APIs at https://learn.microsoft.com/en-us/dotnet/aspire/database/sql-server-entity-framework-component. Should we add something there?
The recommendation for Blazor web applications is to use
AddDBContextFactory
to handle the lifetime of the DBContext, I believeAspire.Microsoft.EntityFrameworkCore.SqlServer
should also provide that method to support that recommendation.PD: Amazing tech