EF.CH
10.1.0
dotnet add package EF.CH --version 10.1.0
NuGet\Install-Package EF.CH -Version 10.1.0
<PackageReference Include="EF.CH" Version="10.1.0" />
<PackageVersion Include="EF.CH" Version="10.1.0" />
<PackageReference Include="EF.CH" />
paket add EF.CH --version 10.1.0
#r "nuget: EF.CH, 10.1.0"
#:package EF.CH@10.1.0
#addin nuget:?package=EF.CH&version=10.1.0
#tool nuget:?package=EF.CH&version=10.1.0
EF.CH
Entity Framework Core provider for ClickHouse
EF.CH brings ClickHouse into the Entity Framework Core ecosystem. Define your models in C#, write LINQ queries, and run migrations -- all against ClickHouse's columnar analytics engine.
Quick Start
dotnet add package EF.CH
using Microsoft.EntityFrameworkCore;
using EF.CH.Extensions;
public class Event
{
public Guid Id { get; set; }
public DateTime Timestamp { get; set; }
public string EventType { get; set; } = string.Empty;
public decimal Amount { get; set; }
}
public class AppDbContext : DbContext
{
public DbSet<Event> Events => Set<Event>();
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseClickHouse("Host=localhost;Port=8123;Database=default");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Event>(entity =>
{
entity.HasKey(e => e.Id);
entity.UseMergeTree(e => new { e.Timestamp, e.EventType })
.HasPartitionBy(e => e.Timestamp, PartitionGranularity.Month);
});
}
}
// Insert
await using var db = new AppDbContext();
await db.Database.EnsureCreatedAsync();
db.Events.Add(new Event
{
Id = Guid.NewGuid(),
Timestamp = DateTime.UtcNow,
EventType = "purchase",
Amount = 99.95m
});
await db.SaveChangesAsync();
// Query
var summary = await db.Events
.GroupBy(e => e.EventType)
.Select(g => new { Type = g.Key, Total = g.Sum(e => e.Amount) })
.ToListAsync();
Feature Highlights
| Category | Highlights | Docs |
|---|---|---|
| Engines | 15 table engines: MergeTree, ReplacingMergeTree, SummingMergeTree, AggregatingMergeTree, CollapsingMergeTree, VersionedCollapsingMergeTree, Replicated variants, Distributed, Null, KeeperMap | docs/engines/ |
| Type System | Arrays, Maps, Tuples, Nested, JSON, IPv4/IPv6, Enums, DateTime64 with timezones, LowCardinality, 40+ type mappings | docs/types/ |
| Query Power | FINAL, SAMPLE, PREWHERE, LimitBy, CTEs, ARRAY JOIN, ASOF JOIN, Window Functions, Set Operations, Interpolate, 22+ LINQ extensions | docs/querying/ |
| Analytics | 66+ aggregate functions, materialized views, projections, aggregate combinators (-If, -Array, -State, -Merge) | docs/functions/, docs/advanced/ |
| Data Operations | Bulk insert, INSERT...SELECT, export to CSV/JSON/Parquet, temp tables | docs/data-operations/ |
| Enterprise | Multi-DC clustering, connection routing, replicated engines, EF Core migrations with ClickHouse DDL | docs/clustering/, docs/migrations/ |
ClickHouse for EF Core Developers
If you are coming from SQL Server or PostgreSQL, ClickHouse works differently in several fundamental ways. EF.CH bridges these gaps where possible and surfaces the differences clearly where it cannot.
| SQL Server / PostgreSQL | ClickHouse | EF.CH API |
|---|---|---|
| Table just works | Must specify ENGINE | .UseMergeTree(x => ...) |
| IDENTITY / SERIAL | No auto-increment | Guid / application-generated IDs |
UPDATE SET ... WHERE |
ALTER TABLE UPDATE (async) |
.ExecuteUpdateAsync() |
| Transaction scope | No transactions | Design for idempotency |
| Foreign keys | None | Application-level joins |
COUNT(DISTINCT x) |
uniq(x) (approx) or uniqExact(x) |
.Uniq() / .UniqExact() |
| Clustered index | ORDER BY in MergeTree | Engine ORDER BY expression |
| Row-level updates | Part-level merges | Background async processing |
See ClickHouse for EF Developers for the full guide.
Requirements
| Dependency | Minimum Version |
|---|---|
| .NET | 8.0+ |
| ClickHouse | 22.0+ |
| EF Core | 8.0+ |
Runtime dependencies: ClickHouse.Driver 0.9.0, Microsoft.EntityFrameworkCore.Relational 8.0.13.
Documentation
| Section | Description |
|---|---|
| Getting Started | Installation, first DbContext, connection strings |
| ClickHouse for EF Developers | Conceptual differences from SQL Server / PostgreSQL |
| Engines | MergeTree family, Replicated, Distributed, Null |
| Types | Arrays, Maps, Nested, JSON, IPv4/IPv6, Enums, DateTime |
| Modeling | Computed columns, codecs, LowCardinality, skip indices, TTL |
| Querying | FINAL, SAMPLE, PREWHERE, LimitBy, CTEs, Window Functions |
| Functions | 66+ aggregates, string, date, hash, IP, URL, encoding functions |
| Data Operations | Bulk insert, INSERT...SELECT, export, temp tables |
| Advanced | Materialized views, projections, parameterized views, dictionaries |
| Clustering | Multi-node setup, connection routing, Distributed engine |
| Migrations | DDL generation, migration splitting, custom operations |
| Scaffolding | Reverse-engineering existing ClickHouse databases |
| Limitations | Known gaps and workarounds |
Samples
All samples are standalone projects in the samples/ directory. Build individually:
dotnet build samples/QuickStartSample/
Getting Started
| Sample | Description |
|---|---|
| QuickStartSample | Minimal setup: DbContext, insert, query |
| TypesSample | ClickHouse type mappings: arrays, maps, enums, IPv4/IPv6 |
| MigrationSample | EF Core migrations with ClickHouse DDL |
Core Features
| Sample | Description |
|---|---|
| EnginesSample | MergeTree family, ReplacingMergeTree, SummingMergeTree |
| QueryFeaturesSample | FINAL, SAMPLE, PREWHERE, LimitBy, CTEs |
| BulkOperationsSample | High-throughput bulk insert and INSERT...SELECT |
| MaterializedViewSample | Materialized views with source and target tables |
| JoinSample | ARRAY JOIN, ASOF JOIN for analytics and time-series |
| DeleteUpdateSample | Lightweight deletes, ALTER TABLE UPDATE strategies |
| IdentifierDefaultsSample | Server-generated IDs: generateSerialID, UUIDv4/v7, ULID, Snowflake |
Advanced
| Sample | Description |
|---|---|
| DictionarySample | ClickHouse dictionaries with EF Core |
| ExternalEntitiesSample | External tables and data sources in queries |
| ClusterSample | Multi-node cluster with Distributed tables |
| QueryProfilingSample | Query profiling and performance analysis |
| ParameterizedViewSample | Parameterized views with typed arguments |
Real-World Patterns
| Sample | Description |
|---|---|
| EventAnalyticsSample | End-to-end event analytics pipeline |
| TempTableWorkflowSample | Temp tables for complex multi-step queries |
License
MIT. See LICENSE for details.
Acknowledgments
Built by Daniel Bunting. Powered by ClickHouse.Driver and Microsoft.EntityFrameworkCore.
| 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. |
-
net10.0
- ClickHouse.Driver (>= 1.0.0)
- Microsoft.EntityFrameworkCore.Design (>= 10.0.7)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.7)
- SqlParserCS (>= 0.6.5)
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 |
|---|---|---|
| 10.1.0 | 93 | 5/7/2026 |
| 10.0.4 | 120 | 3/29/2026 |
| 9.0.5 | 104 | 3/26/2026 |
| 8.1.1 | 165 | 3/26/2026 |
| 8.1.0 | 109 | 2/24/2026 |
| 8.0.9 | 105 | 2/17/2026 |
| 8.0.8 | 123 | 1/30/2026 |
| 8.0.7 | 125 | 1/8/2026 |
| 8.0.6 | 120 | 1/8/2026 |
| 8.0.5 | 131 | 1/7/2026 |
| 8.0.4 | 124 | 1/7/2026 |
| 8.0.3 | 117 | 1/6/2026 |
| 0.0.25 | 119 | 1/8/2026 |
| 0.0.24 | 121 | 1/7/2026 |
| 0.0.23 | 118 | 1/7/2026 |
| 0.0.22 | 123 | 1/6/2026 |
| 0.0.21 | 116 | 1/6/2026 |