Aiursoft.ClickhouseSdk 10.0.13

There is a newer version of this package available.
See the version list below for details.
dotnet add package Aiursoft.ClickhouseSdk --version 10.0.13
                    
NuGet\Install-Package Aiursoft.ClickhouseSdk -Version 10.0.13
                    
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="Aiursoft.ClickhouseSdk" Version="10.0.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aiursoft.ClickhouseSdk" Version="10.0.13" />
                    
Directory.Packages.props
<PackageReference Include="Aiursoft.ClickhouseSdk" />
                    
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 Aiursoft.ClickhouseSdk --version 10.0.13
                    
#r "nuget: Aiursoft.ClickhouseSdk, 10.0.13"
                    
#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 Aiursoft.ClickhouseSdk@10.0.13
                    
#: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=Aiursoft.ClickhouseSdk&version=10.0.13
                    
Install as a Cake Addin
#tool nuget:?package=Aiursoft.ClickhouseSdk&version=10.0.13
                    
Install as a Cake Tool

Aiursoft ClickHouse SDK & Logger Provider

MIT licensed Pipeline stat Test Coverage NuGet version (Aiursoft.ClickhouseSdk) Man hours

A high-performance, textbook-grade ClickHouse integration suite for .NET applications. It provides an effortless way to interact with ClickHouse using a "DbContext" style pattern and a high-performance logging provider for the standard Microsoft.Extensions.Logging infrastructure.

Key Features

  • Automatic Schema Management: Automatically creates databases and tables. Supports schema evolution (automatically adds missing columns).
  • High-Performance Bulk Writing: Uses ClickHouseBulkCopy for asynchronous, non-blocking batch uploads.
  • Background Log Flushing: Buffered logging with background flushing to ensure zero impact on application performance.
  • Clean Configuration: Standard ClickHouse connection strings. Table names are managed through code or configuration.

Project 1: Aiursoft.ClickhouseSdk (Core SDK)

The core SDK provides the base infrastructure for ClickHouse communication.

Installation

dotnet add package Aiursoft.ClickhouseSdk

Basic Usage

  1. Define your Entity: Create a class representing your data row.

  2. Create your DbContext: Inherit from ClickhouseDbContext and define your sets.

using Aiursoft.ClickhouseSdk;
using Aiursoft.ClickhouseSdk.Abstractions;

public class MyDbContext : ClickhouseDbContext
{
    public ClickhouseSet<MyEntity> MyEntities { get; }

    public MyDbContext(IOptionsMonitor<ClickhouseOptions> options) : base(options)
    {
        // Define the mapping from your entity to ClickHouse row objects
        // You can have multiple sets mapping to different tables in the same database!
        MyEntities = new ClickhouseSet<MyEntity>(GetConnection, "MyTableName", entity => new object[] 
        {
            entity.Id,
            entity.Name,
            entity.CreatedAt
        });
    }

    public override async Task SaveChangesAsync()
    {
        await MyEntities.SaveChangesAsync();
    }
}
  1. Register and Configure: In your Program.cs, register your DbContext and bind the configuration.
// 1. Bind configuration (from appsettings.json or environment variables)
builder.Services.Configure<ClickhouseOptions>(options => 
{
    options.ConnectionString = "Host=localhost;Database=MyBusinessDb;User=default;Password=password";
});

// 2. Register your custom DbContext
builder.Services.AddSingleton<MyDbContext>();
  1. Initialize the Schema: Call InitClickhouseTableAsync<T> during application startup.
// This will ensure 'MyTableName' exists in the database defined in your connection string.
await host.Services.InitClickhouseTableAsync<MyEntity>("MyTableName", "CreatedAt"); 

Configuration via appsettings.json

Both projects use the same ClickhouseOptions structure. You can define your settings in appsettings.json:

{
  "Clickhouse": {
    "ConnectionString": "Host=localhost;Database=DemoDb;User=default;Password=password",
    "TableName": "AppLogs", 
    "Enabled": true
  }
}

And bind it in your code:

builder.Services.Configure<ClickhouseOptions>(builder.Configuration.GetSection("Clickhouse"));

Project 2: Aiursoft.ClickhouseLoggerProvider (Logging)

A specialized provider that redirects standard ILogger output to ClickHouse.

Installation

dotnet add package Aiursoft.ClickhouseLoggerProvider

Registration

Register the provider in your application builder.

builder.Logging.AddClickhouse(options => 
{
    options.ConnectionString = "Host=localhost;Protocol=http;Port=8123;User=default;Password=password;Database=MyLogs";
    options.TableName = "AppLogs"; // Optional, defaults to "AppLogs"
});

Initialization

Ensure the logging table is initialized at startup.

await host.Services.InitLoggingTableAsync();

How to Contribute

We welcome contributions! Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch.
  3. Ensure all code passes lint.sh and all tests pass.
  4. Submit a Pull Request.

License

This project is licensed under the MIT License.

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 (1)

Showing the top 1 NuGet packages that depend on Aiursoft.ClickhouseSdk:

Package Downloads
Aiursoft.ClickhouseLoggerProvider

A high-performance logging provider that redirects standard .NET ILogger output to ClickHouse.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.18 187 4/22/2026
10.0.17 215 4/15/2026
10.0.16 288 3/29/2026
10.0.13 102 3/29/2026
10.0.11 99 3/29/2026
10.0.10 106 3/26/2026
10.0.8 99 3/26/2026
10.0.5 101 3/26/2026