Skip to main content
net10.0net8.0net9.0

An Aspire client integration for the Microsoft.EntityFrameworkCore.Sqlite package.

Published
Sep 28, 2026
21d ago
Total Downloads
67.6K
67,567

Install

dotnet add package CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite --version 13.5.1-beta.779
ProductVersions
.NET
net10.0net8.0net9.0

README

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

Feedback & contributing

https://github.com/CommunityToolkit/Aspire

Changes from Previous Version

No structural changes between v13.5.1-beta.777 and v13.5.1-beta.779.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.The published metadata declares 21 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.