ClickHouse provider for Entity Framework Core.
License
—
Deps
5
Install Size
—
Vulns
✓ 0
Published
Nov 19, 2023
$ dotnet add package EFCore.ClickHouseSupport Migrations.
All schemas will set to null on model creating, if you want to use Schemas (which will consider as Database prefix in clickhouse) you need to set them manually after base.OnModelCreating()
add, drop and rename column not supported by some table engine type, so the only way is to recreate them, u need to use .HasCreateStrategy(TableCreationStrategy.CREATE_OR_REPLACE) FluentApi on the entityBuilder.
to specify engine type you can use these methods in onModelCreating :
like this:
var user = modelBuilder.Entity<User>();
user.HasPostGresEngine("User", "Accounting");
you can set partitioning expression as string as well. and if you partition by a date/datetime column you can use PartitionByDateFormat enum to further config it:
HasPartitionBy(a=> a.Date,PartitionByDateFormat.Month)
which is :
toYYYYMM(Date)
you can chain them as well.
user.HasMergeTreeEngine(a => { a.Settings = new(); a.Settings.MergeMaxBlockSize = 2048; a.Settings.IndexGranularityBytes = 1024; a.Settings.MinRowsForWidePart = 512; });
to configure entity types dynamically you can use these extension methods:
var entityTypes = modelBuilder.Model.GetEntityTypes();
foreach (var entityType in entityTypes)
{
entityType.HasCreateStrategy(TableCreationStrategy.CREATE);
entityType.HasPostGresEngine();
}