ClickHouse.Facades
2.9.1
dotnet add package ClickHouse.Facades --version 2.9.1
NuGet\Install-Package ClickHouse.Facades -Version 2.9.1
<PackageReference Include="ClickHouse.Facades" Version="2.9.1" />
<PackageVersion Include="ClickHouse.Facades" Version="2.9.1" />
<PackageReference Include="ClickHouse.Facades" />
paket add ClickHouse.Facades --version 2.9.1
#r "nuget: ClickHouse.Facades, 2.9.1"
#:package ClickHouse.Facades@2.9.1
#addin nuget:?package=ClickHouse.Facades&version=2.9.1
#tool nuget:?package=ClickHouse.Facades&version=2.9.1
ClickHouse.Facades
.NET package for managing ClickHouse migrations and organizing raw SQL through structured database contexts. Makes it easy to separate concerns across features, services, or tables. Built on ClickHouse.Client and tested in production.
This is an unofficial package and is not affiliated with or endorsed by ClickHouse Inc.
"ClickHouse" is a registered trademark of ClickHouse Inc. — clickhouse.com
Key Features
- Migrations: allows you to perform raw SQL migrations on your ClickHouse database.
- Rollback support
- Supports file-based migrations
- Customizable migration file name parser
- Customizable file content parser
- Supports code-defined (inline) migrations using C# classes
- Conditional migrations based on ClickHouse server version
- Migration template for .NET CLI
- Contexts: provides a way to work with ClickHouse contexts, allowing you to organize your database operations in a structured manner.
- Context-specific migrations, allowing separate migration management for distinct packages or components
- Parametrized queries (anonymous type parameters supported)
- Query cancellation by termination on ClickHouse side
- Transactions support (keeper is required)
- Retryable contexts
- Dapper compatibility (reader deserialization)
- Provides all the features of the ClickHouse.Client package
- Fully async contract
- Testing toolkit: provides tools for unit testing components of ClickHouse.Facades with the dedicated ClickHouse.Facades.Testing package.
- Facades mocking
- Specific requests mocking and tracking
- Comprehensive documentation presented in repository Wiki.
Migrations Usage
Implement IClickHouseMigrationInstructions
and IClickHouseMigrationsLocator
(example)
and register them as DI services
services.AddClickHouseMigrations<ClickHouseMigrationInstructions, ClickHouseMigrationsLocator>();
You can request IClickHouseMigrator
service or use IServiceProviderExtensions
to manage migrations
await serviceProvider.ClickHouseMigrateAsync();
Add Migrations
Add ClickHouseMigration
inheritor with ClickHouseMigration
attribute
[ClickHouseMigration(202310240941, "ExampleMigration")]
public class ExampleMigration : ClickHouseMigration
{
protected override void Up(ClickHouseMigrationBuilder migrationBuilder)
{
// migrationBuilder.AddRawSqlStatement("create table if not exists ...")
}
protected override void Down(ClickHouseMigrationBuilder migrationBuilder)
{
// migrationBuilder.AddRawSqlStatement("drop table if exists ...")
}
}
The index of ClickHouseMigrationAttribute
is used to order migrations. It's best to always use idempotent statements (for example with if [not] exists
) since migration may fail.
Context Usage
Implement the following class inheritors: ClickHouseContext<TContext>
, ClickHouseContextFactory<TContext>
, ClickHouseFacade<TContext>
(example)
and register them as DI services
services.AddClickHouseContext<ExampleContext, ExampleContextFactory>(builder => builder
.AddFacade<UsersFacade>()
.AddFacade<OrdersFacade>());
Request IClickHouseContextFactory<TContext>
service to create context
await using var context = await contextFactory.CreateContextAsync();
var ordersFacade = context.GetFacade<OrdersFacade>();
await ordersFacade.GetOrders();
You can create as many contexts as you need with any number of facades. Facades are built via DI and are stateful within context lifetime.
You can perform migrations on your ClickHouse database without the necessity of implementing contexts.
Examples
For a deeper understanding and practical use cases of how to implement migrations and facades, please refer to the examples folder provided in the repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- ClickHouse.Client (>= 7.14.0)
- System.Linq.Async (>= 6.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ClickHouse.Facades:
Package | Downloads |
---|---|
ClickHouse.Facades.Testing
Provides tools for unit testing ClickHouse.Facades components |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.9.1 | 164 | 8/2/2025 |
2.8.1 | 204 | 7/28/2025 |
2.7.1 | 304 | 7/7/2025 |
2.6.1 | 162 | 7/4/2025 |
2.5.11 | 806 | 5/12/2025 |
2.5.10 | 188 | 4/22/2025 |
2.5.9 | 839 | 3/25/2025 |
2.5.8 | 308 | 3/12/2025 |
2.5.7 | 220 | 3/9/2025 |
2.5.6 | 162 | 2/25/2025 |
2.5.5 | 153 | 1/27/2025 |
2.5.4 | 286 | 11/21/2024 |
2.5.3 | 250 | 10/14/2024 |
2.5.2 | 1,059 | 9/24/2024 |
2.5.1 | 184 | 8/29/2024 |
2.4.2 | 178 | 8/27/2024 |
2.4.1 | 305 | 8/5/2024 |
2.3.1 | 157 | 7/19/2024 |
2.2.2 | 314 | 7/15/2024 |
2.2.1 | 202 | 6/18/2024 |
2.1.3 | 190 | 6/17/2024 |
2.1.2 | 179 | 6/14/2024 |
2.1.1 | 173 | 6/6/2024 |
2.0.1 | 180 | 6/4/2024 |
1.2.1 | 212 | 6/2/2024 |
1.1.2 | 184 | 5/19/2024 |
1.1.1 | 156 | 5/14/2024 |
1.0.8 | 201 | 4/18/2024 |
1.0.7 | 187 | 4/17/2024 |
1.0.6 | 197 | 3/26/2024 |
1.0.5 | 186 | 3/21/2024 |
1.0.4 | 219 | 2/22/2024 |
1.0.3 | 205 | 2/5/2024 |
1.0.2 | 299 | 11/2/2023 |
1.0.1 | 179 | 11/2/2023 |
1.0.0 | 163 | 10/26/2023 |