denis-ivanov / EntityFrameworkCore.ClickHouse

ClickHouse provider for Entity Framework Core.
https://clickhouse.tech/
8 stars 1 forks source link

How to use your library? #33

Open RedPowDan opened 3 weeks ago

RedPowDan commented 3 weeks ago

Hello!) I'm trying to implement your library into my project, but I can't install it. Help me please. Are there any examples of how to install it?

public class HistoryDbContext : Microsoft.EntityFrameworkCore.DbContext
{
    #region Constructors

    /// <inheritdoc />
    public HistoryDbContext(DbContextOptions<HistoryDbContext> options) : base(options)
    {
    }

    #endregion

    #region DbSets

    public DbSet<ChangeHistory> ChangeHistory { get; set; }

    #endregion
}

public class HistoryDbContextDesignTimeFactory : IDesignTimeDbContextFactory<HistoryDbContext>
{
    /// <inheritdoc />
    public HistoryDbContext CreateDbContext(string[] args) => CreateDbContext("_");

    public HistoryDbContext CreateDbContext(string connectionString)
    {
        var optionsBuilder = new DbContextOptionsBuilder<HistoryDbContext>();
        optionsBuilder.UseClickHouse(connectionString)
            .ReplaceService<IMigrationsIdGenerator, MigrationsIdGenerator>()
            .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
        return new HistoryDbContext(optionsBuilder.Options);
    }
}
dotnet ef migrations add Migration00001 --context HistoryDbContext --project SkinTrove.DataAccess.ClickHouse --startup-project DatabaseMigrator
Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Design.IAnnotationCodeGenerator' while attempting to activate 'Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsCodeGeneratorDependencies'.
denis-ivanov commented 3 weeks ago

Hi, @RedPowDan ! The library is not implemented completely, that's why you will get error messages. Leave full example how to reproduce the issue, may I will find free time in the future.

RedPowDan commented 1 week ago

Hi, @denis-ivanov!) Thank you very much for adding the description in Readme, I’ll return to the clickhouse problem in the near future!

denis-ivanov commented 1 week ago

Last changes still do not support migrations, you can generate them, but not apply, scaffolding should work