I am trying to generate entity from a clickhouse database in to my ASP.NET Core 8 Web API project.
I installed these packages:
<ItemGroup>
<PackageReference Include="ClickHouse.Client" Version="7.7.3" />
<PackageReference Include="EFCore.ClickHouse" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
I and tried like this:
dotnet ef dbcontext scaffold "Host=127.0.0.1;Port=8123;User=default;Password=;Database=db2;Compress=True;CheckCompressedHash=False;SocketTimeout=60000000;Compressor=lz4" EFCore.ClickHouse -o Models -c MyDbContext
I got this error:
Unable to find expected assembly attribute [DesignTimeProviderServices] in provider assembly 'EFCore.ClickHouse'. This attribute is required to identify the class which acts as the design-time service provider factory for the provider.
I confirm that my connection string is correct, I had successfully used this connection string to access clickhousedb from my code before.
How to scaffold entity from Clickhouse database in an ASP.NET Core Web API project?
You can use this package to scaffold you clickhouse database to entity
https://github.com/denis-ivanov/EntityFrameworkCore.ClickHouse
Follow these steps:
dotnet add package EntityFrameworkCore.ClickHouse
dotnet add package Spectre.Console.Cli
dotnet ef dbcontext scaffold "Host=127.0.0.1;Port=8123;User=default;Password=;Database=db2;Compress=True;CheckCompressedHash=False;SocketTimeout=60000000;Compressor=lz4" EntityFrameworkCore.ClickHouse -o Models -c MyDbContext