EntityFrameworkCore.ClickHouse icon indicating copy to clipboard operation
EntityFrameworkCore.ClickHouse copied to clipboard

How to use your library?

Open RedPowDan opened this issue 1 year ago • 3 comments

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'.

RedPowDan avatar Apr 28 '24 18:04 RedPowDan

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.

denis-ivanov avatar Apr 29 '24 13:04 denis-ivanov

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

RedPowDan avatar May 10 '24 11:05 RedPowDan

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

denis-ivanov avatar May 10 '24 13:05 denis-ivanov

@RedPowDan, can you try latest version?

denis-ivanov avatar Jul 23 '24 18:07 denis-ivanov

@RedPowDan, can you try latest version?

Hi!) Yes, I tried the latest version, but I don't use the library on my project yet, because there is no need to write information to ClickHouse right now, I only want to store the history of user actions there

RedPowDan avatar Aug 04 '24 08:08 RedPowDan

@denis-ivanov, Can you please tell me where it is better to rent ClickHouse for a small amount for a test server?

RedPowDan avatar Aug 04 '24 08:08 RedPowDan