-
Notifications
You must be signed in to change notification settings - Fork 153
Description
Related to an existing integration?
Yes
Summary
Currently, EF Core offers provider‑specific helper methods for certain databases (e.g., in the Oracle provider) that simplify DbContext registration and configuration.
For SQLite, there is no equivalent single‑call method, requiring developers to manually configure in .
Additionally, this method should optionally integrate OpenTelemetry tracing and metrics for EF Core operations when the package (or other OTel instrumentation) is present.
This would align with .NET Aspire’s built‑in observability model and leverage OpenTelemetry’s EF Core instrumentation.
Motivation
• Consistency: Aligns SQLite developer experience with other EF Core providers that already have methods.
• Reduced boilerplate: Eliminates repetitive + setup code.
• Onboarding speed: Makes it easier for new developers to configure SQLite with minimal ceremony.
• Parity: Encourages a uniform API surface across providers.
• Observability: Out‑of‑the‑box OpenTelemetry support for EF Core queries, leveraging Aspire’s telemetry pipeline and the OpenTelemetry .NET automatic instrumentation for EF Core(9).
Proposed API
public static WebApplicationBuilder EnrichSqliteDatabaseDbContext<TDbContext>(
this WebApplicationBuilder builder,
string? connectionStringName = "DefaultConnection",
bool enableOpenTelemetry = true)
where TDbContext : DbContext
{
var connectionString = builder.Configuration.GetConnectionString(connectionStringName);
builder.Services.AddDbContext<TDbContext>(options =>
options.UseSqlite(connectionString));
if (enableOpenTelemetry)
{
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddEntityFrameworkCoreInstrumentation()
.AddOtlpExporter());
}
return builder;
}
Additional Notes
• OpenTelemetry EF Core instrumentation is already supported in .NET via .
• This proposal would make SQLite + EF Core + OTel a one‑liner in Aspire projects.
• Could be implemented in to keep it consistent with Aspire’s integration model.