EntityFrameworkCore.ClickHouse
EntityFrameworkCore.ClickHouse copied to clipboard
Error while insert
The instance of entity type 'DistributorStockSale' cannot be tracked because another instance with the same key value for {'CompanyId', 'DateKey'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values.
protected override void OnModelCreating(ModelBuilder modelBuilder) { var entityTypeBuilder = modelBuilder.Entity<DistributorStockSale>();
entityTypeBuilder.HasKey(e => new { e.CompanyId, e.DateKey });
entityTypeBuilder.ToTable("DistributorStockSale", table => table
.HasMergeTreeEngine()
.WithPrimaryKey("CompanyId", "DateKey"));
}
I am getting this error while using AddRangeAsync();
If the error i am getting is due to the multiple records with same companyid and datekey being inserted at a time, should not we handle this for clickhouse as clickhouse does not enforce unique primary key concept?