CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite
13.2.1-beta.532
Prefix Reserved
dotnet add package CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite --version 13.2.1-beta.532
NuGet\Install-Package CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite -Version 13.2.1-beta.532
<PackageReference Include="CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite" Version="13.2.1-beta.532" />
<PackageVersion Include="CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite" Version="13.2.1-beta.532" />
<PackageReference Include="CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite" />
paket add CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite --version 13.2.1-beta.532
#r "nuget: CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite, 13.2.1-beta.532"
#:package CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite@13.2.1-beta.532
#addin nuget:?package=CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite&version=13.2.1-beta.532&prerelease
#tool nuget:?package=CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite&version=13.2.1-beta.532&prerelease
CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite library
Register a DbContext in the DI container to interact with a SQLite database using Entity Framework Core.
Getting Started
Prerequisites
- A
DbContext - A SQLite database
Install the package
Install the Aspire EF Core Sqlite library using the following command:
dotnet add package CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite
Example usage
Option 1: Using IHostApplicationBuilder (Traditional Aspire Pattern)
In the Program.cs file of your project, call the AddSqliteDbContext<TDbContext> extension method to register the TDbContext implementation in the DI container. This method takes the connection name as a parameter:
builder.AddSqliteDbContext<BloggingContext>("sqlite");
Option 2: Using WebApplicationBuilder (New Simplified Pattern)
For ASP.NET Core applications, you can use the simplified EnrichSqliteDatabaseDbContext<TDbContext> extension method:
// Basic usage with default connection string name "DefaultConnection"
builder.EnrichSqliteDatabaseDbContext<BloggingContext>();
// With custom connection string name
builder.EnrichSqliteDatabaseDbContext<BloggingContext>("MyConnection");
// Disable OpenTelemetry instrumentation
builder.EnrichSqliteDatabaseDbContext<BloggingContext>(enableOpenTelemetry: false);
The EnrichSqliteDatabaseDbContext method provides:
- Simplified API: Works directly with
WebApplicationBuilder - Default connection string: Uses "DefaultConnection" by default
- OpenTelemetry integration: Automatically adds EF Core instrumentation for distributed tracing
- Parameter validation: Proper error handling for missing connection strings
Then, in your service, inject TDbContext and use it to interact with the database:
public class MyService(BloggingContext context)
{
// ...
}
Additional documentation
- https://learn.microsoft.com/dotnet/aspire/community-toolkit/sqlite-entity-framework-integration
- https://learn.microsoft.com/ef/core/providers/sqlite/
Feedback & contributing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.EntityFrameworkCore.Sqlite (>= 10.0.2)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore (>= 10.0.2)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.2)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.12.0-beta.2)
-
net8.0
- Microsoft.EntityFrameworkCore.Sqlite (>= 8.0.23)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.23)
- Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore (>= 8.0.23)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.2)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.12.0-beta.2)
-
net9.0
- Microsoft.EntityFrameworkCore.Sqlite (>= 9.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.9)
- Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore (>= 9.0.9)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.2)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.12.0-beta.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 13.2.1-beta.532 | 65 | 3/13/2026 |
| 13.2.1-beta.531 | 54 | 3/11/2026 |
| 13.2.1-beta.528 | 50 | 3/5/2026 |
| 13.1.2-beta.518 | 163 | 2/17/2026 |
| 13.1.2-beta.516 | 70 | 2/9/2026 |
| 13.1.2-beta.515 | 67 | 2/2/2026 |
| 13.1.2-beta.514 | 56 | 1/30/2026 |
| 13.1.2-beta.513 | 56 | 1/29/2026 |
| 13.1.2-beta.512 | 57 | 1/29/2026 |
| 13.1.2-beta.511 | 63 | 1/28/2026 |
| 13.1.2-beta.509 | 61 | 1/20/2026 |
| 13.1.2-beta.508 | 73 | 1/19/2026 |
| 13.1.2-beta.507 | 60 | 1/19/2026 |
| 13.1.2-beta.506 | 62 | 1/16/2026 |
| 13.1.2-beta.505 | 65 | 1/16/2026 |
| 13.1.2-beta.504 | 53 | 1/16/2026 |
| 13.1.1-preview.1.260116-0117 | 65 | 1/16/2026 |
| 13.1.1-beta.502 | 60 | 1/16/2026 |
| 13.1.0-preview.1.260114-1049 | 63 | 1/14/2026 |
| 9.7.2 | 5,590 | 8/29/2025 |