CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite
17.0.1-beta.1093
Prefix Reserved
dotnet add package CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite --version 17.0.1-beta.1093
NuGet\Install-Package CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite -Version 17.0.1-beta.1093
<PackageReference Include="CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite" Version="17.0.1-beta.1093" />
<PackageVersion Include="CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite" Version="17.0.1-beta.1093" />
<PackageReference Include="CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite" />
paket add CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite --version 17.0.1-beta.1093
#r "nuget: CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite, 17.0.1-beta.1093"
#:package CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite@17.0.1-beta.1093
#addin nuget:?package=CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite&version=17.0.1-beta.1093&prerelease
#tool nuget:?package=CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite&version=17.0.1-beta.1093&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 | 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. net11.0 is compatible. |
-
net10.0
- Microsoft.EntityFrameworkCore.Sqlite (>= 10.0.2)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.15)
- 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.18.0)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.15.1-beta.1)
- SQLitePCLRaw.lib.e_sqlite3 (>= 2.1.12)
-
net11.0
- Microsoft.EntityFrameworkCore.Sqlite (>= 10.0.2)
- Microsoft.Extensions.Configuration.Binder (>= 11.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore (>= 10.0.2)
- OpenTelemetry.Extensions.Hosting (>= 1.18.0)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.15.1-beta.1)
- SQLitePCLRaw.lib.e_sqlite3 (>= 2.1.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite:
| Repository | Stars |
|---|---|
|
rstropek/Samples
|
| Version | Downloads | Last Updated |
|---|---|---|
| 17.0.1-beta.1093 | 69 | 12/1/2026 |
| 17.0.0-preview.1.261120-0454 | 103 | 11/20/2026 |
| 17.0.0-beta.1090 | 76 | 11/20/2026 |
| 17.0.0-beta.1088 | 66 | 11/20/2026 |
| 17.0.0-beta.1080 | 116 | 11/20/2026 |
| 17.0.0-beta.1078 | 84 | 11/19/2026 |
| 17.0.0-beta.1077 | 67 | 11/19/2026 |
| 17.0.0-beta.1076 | 59 | 11/19/2026 |
| 17.0.0-beta.1075 | 60 | 11/19/2026 |
| 17.0.0-beta.1052 | 80 | 11/16/2026 |
| 17.0.0-beta.1051 | 79 | 11/12/2026 |
| 17.0.0-beta.1033 | 71 | 11/10/2026 |
| 17.0.0-beta.1022 | 75 | 11/8/2026 |
| 17.0.0-beta.1018 | 70 | 11/6/2026 |
| 17.0.0-beta.1009 | 67 | 11/5/2026 |
| 17.0.0-beta.994 | 68 | 11/4/2026 |
| 17.0.0-beta.993 | 64 | 11/4/2026 |
| 13.6.2-beta.959 | 113 | 10/27/2026 |
| 13.6.1-preview.1.261026-0455 | 95 | 10/26/2026 |
| 9.7.2 | 9,958 | 8/29/2025 |