CSharpDB.EntityFrameworkCore 3.8.0

Prefix Reserved
dotnet add package CSharpDB.EntityFrameworkCore --version 3.8.0
                    
NuGet\Install-Package CSharpDB.EntityFrameworkCore -Version 3.8.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSharpDB.EntityFrameworkCore" Version="3.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharpDB.EntityFrameworkCore" Version="3.8.0" />
                    
Directory.Packages.props
<PackageReference Include="CSharpDB.EntityFrameworkCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSharpDB.EntityFrameworkCore --version 3.8.0
                    
#r "nuget: CSharpDB.EntityFrameworkCore, 3.8.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CSharpDB.EntityFrameworkCore@3.8.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSharpDB.EntityFrameworkCore&version=3.8.0
                    
Install as a Cake Addin
#tool nuget:?package=CSharpDB.EntityFrameworkCore&version=3.8.0
                    
Install as a Cake Tool

CSharpDB.EntityFrameworkCore

Entity Framework Core 10 provider for the CSharpDB embedded database engine. Use standard EF Core DbContext, migrations, and LINQ patterns against embedded file-backed or private in-memory CSharpDB databases.

NuGet .NET 10 Release License: MIT

Overview

CSharpDB.EntityFrameworkCore adds an embedded-only EF Core provider on top of CSharpDB.Data. It supports the current CSharpDB relational runtime with:

  • UseCSharpDb(...) provider configuration
  • file-backed runtime and migrations
  • private :memory: runtime when you keep a CSharpDbConnection open
  • EnsureCreated(), Database.Migrate(), and standard dotnet ef flows
  • CRUD, change tracking, concurrency row-count checks, and a focused LINQ subset

This package is intentionally scoped as a v1 embedded provider. It does not target daemon/client transports, pooled connections, or broad schema-rebuild emulation.

Installation

dotnet add package CSharpDB.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.Design

Microsoft.EntityFrameworkCore.Design is still recommended in the application project so dotnet ef can run design-time commands cleanly.

Usage

using CSharpDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

public sealed class BloggingContext : DbContext
{
    private readonly string? _connectionString;

    public BloggingContext(string databasePath)
        => _connectionString = $"Data Source={databasePath}";

    public BloggingContext(DbContextOptions<BloggingContext> options)
        : base(options)
    {
    }

    public DbSet<Blog> Blogs => Set<Blog>();
    public DbSet<Post> Posts => Set<Post>();

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        if (!optionsBuilder.IsConfigured && _connectionString is not null)
            optionsBuilder.UseCSharpDb(_connectionString);
    }
}

public sealed class Blog
{
    public int Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public List<Post> Posts { get; set; } = [];
}

public sealed class Post
{
    public int Id { get; set; }
    public int BlogId { get; set; }
    public string Title { get; set; } = string.Empty;
    public Blog Blog { get; set; } = null!;
}

Then use EF Core as usual:

await using var db = new BloggingContext("blogging.db");
await db.Database.EnsureCreatedAsync();

db.Blogs.Add(new Blog
{
    Name = "Engineering",
    Posts = [new Post { Title = "Hello from CSharpDB EF Core" }]
});

await db.SaveChangesAsync();

var blogs = await db.Blogs
    .Include(b => b.Posts)
    .OrderBy(b => b.Name)
    .ToListAsync();

Using an Existing Connection

For a private in-memory database, open and keep the CSharpDbConnection alive for the entire DbContext lifetime:

using CSharpDB.Data;
using CSharpDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

await using var connection = new CSharpDbConnection("Data Source=:memory:");
await connection.OpenAsync();

var options = new DbContextOptionsBuilder<BloggingContext>()
    .UseCSharpDb(connection)
    .Options;

await using var db = new BloggingContext(options);
await db.Database.EnsureCreatedAsync();

Embedded Storage Tuning

The EF Core provider can now push the embedded engine tuning surface down into the CSharpDbConnection it creates.

Use named presets and embedded open mode:

using CSharpDB.Data;
using CSharpDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

var options = new DbContextOptionsBuilder<BloggingContext>()
    .UseCSharpDb(
        "Data Source=blogging.db",
        csharpdb =>
        {
            csharpdb.UseStoragePreset(CSharpDbStoragePreset.WriteOptimized);
            csharpdb.UseEmbeddedOpenMode(CSharpDbEmbeddedOpenMode.HybridIncrementalDurable);
        })
    .Options;

Use full direct or hybrid options when you want exact engine composition:

using CSharpDB.Engine;

var directOptions = new DatabaseOptions()
    .ConfigureStorageEngine(builder => builder.UseWriteOptimizedPreset());

var options = new DbContextOptionsBuilder<BloggingContext>()
    .UseCSharpDb(
        "Data Source=blogging.db",
        csharpdb => csharpdb.UseDirectDatabaseOptions(directOptions))
    .Options;

Provider builder methods:

  • UseDirectDatabaseOptions(DatabaseOptions)
  • UseHybridDatabaseOptions(HybridDatabaseOptions)
  • UseStoragePreset(CSharpDbStoragePreset)
  • UseEmbeddedOpenMode(CSharpDbEmbeddedOpenMode)

Precedence rules:

  • explicit DirectDatabaseOptions override Storage Preset
  • explicit HybridDatabaseOptions override Embedded Open Mode
  • provider builder tuning is validated, not applied mutably, when EF Core is given an existing CSharpDbConnection

Migrations

For file-backed databases, the normal EF Core workflow is supported:

dotnet ef migrations add InitialCreate
dotnet ef database update
dotnet ef migrations script

Database.Migrate() is supported for file-backed databases. Migrations use the standard __EFMigrationsHistory table plus a simple __EFMigrationsLock row to serialize concurrent migration runs across processes.

Supported v1 Surface

Area Supported Notes
Embedded runtime provider Yes No daemon or remote transports
File-backed databases Yes Primary supported runtime and migration mode
Private :memory: runtime Yes Requires an open CSharpDbConnection
EnsureCreated() Yes File-backed and private in-memory
Database.Migrate() Yes File-backed only
dotnet ef migrations add Yes Use the app project with Microsoft.EntityFrameworkCore.Design
dotnet ef database update Yes File-backed only
dotnet ef migrations script Yes Non-idempotent scripts only
CRUD + change tracking Yes Includes affected-row concurrency checks
Integer identity propagation Yes Single-column integer primary keys
Basic LINQ/query subset Yes Where, ordering, pagination, scalar projections, First/Single, Any, Count, null checks, Contains, and simple navigation-loading joins
Supported CLR types Yes bool, integral types, enums, double, float, string, Guid, DateTime, DateTimeOffset, DateOnly, TimeOnly, byte[]

Current Limitations

  • decimal requires an explicit value converter
  • schemas are unsupported in runtime and migrations
  • defaults, computed columns, check constraints, and rowversion are unsupported
  • pooled connections are rejected
  • named shared-memory databases (:memory:<name>) are rejected
  • standalone foreign-key alteration migrations are unsupported
  • idempotent migration scripts are unsupported in v1

Dependencies

The provider depends on:

  • CSharpDB.Data for the ADO.NET connection and command layer
  • Microsoft.EntityFrameworkCore.Relational
Package Description
CSharpDB All-in-one package for core application development
CSharpDB.Data Underlying ADO.NET provider used by the EF Core provider
CSharpDB.Engine Embedded database engine below the relational/provider layers

Docs and Samples

License

MIT - see LICENSE for details.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
3.8.0 89 5/17/2026
3.7.0 99 5/9/2026
3.6.0 110 5/3/2026
3.5.0 104 4/28/2026
3.4.0 103 4/25/2026
3.3.0 97 4/23/2026
3.2.0 100 4/19/2026