You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of thank you for all the great work you guys do on this library.
So the issue I've experienced is using the BulkInsertOrUpdateAsync extension method and supplying update properties in the BulkConfig. When executed the action fails with the below error:
Exception data:
Severity: ERROR
SqlState: 42704
MessageText: index "<indexName>" does not exist
File: tablecmds.c
Line: 1299
Routine: DropErrorMsgNonExistent
I've created the below small program that replicates the issue:
usingEFCore.BulkExtensions;usingMicrosoft.EntityFrameworkCore;usingSystem.ComponentModel.DataAnnotations;namespaceEFBulkExtensionsPostgresIssue{internalclassProgram{staticasyncTaskMain(string[]args){varoptionsBuilder=newDbContextOptionsBuilder<BloggingContext>();varconnectionString=Environment.GetEnvironmentVariable("DB_CONNECTION_STRING");optionsBuilder.UseNpgsql(connectionString);usingvarcontext=newBloggingContext(optionsBuilder.Options);varcanConnect=awaitcontext.Database.CanConnectAsync();if(!canConnect){Console.WriteLine("Cannot connect to database");return;}varitems=newList<BlogAggregation>();Randomrnd=new();for(vari=0;i<20;i++){items.Add(newBlogAggregation{Id=Guid.NewGuid(),AggregationTypeId=1,CreatedAt=DateTime.UtcNow,Value=rnd.Next(),AggregationDate=DateTime.UtcNow.AddDays(i*-1)});}varbulkConfig=newBulkConfig{UpdateByProperties=[nameof(BlogAggregation.AggregationTypeId),nameof(BlogAggregation.AggregationDate)],PropertiesToIncludeOnUpdate=[nameof(BlogAggregation.Value),nameof(BlogAggregation.CreatedAt)]};awaitcontext.BulkInsertOrUpdateAsync(items,bulkConfig);}}publicclassBlogAggregation{[Key]publicGuidId{get;init;}publicintAggregationTypeId{get;init;}publicintValue{get;init;}publicDateTimeCreatedAt{get;init;}publicDateTimeAggregationDate{get;init;}}publicclassBloggingContext:DbContext{publicDbSet<BlogAggregation>BlogAggregations{get;set;}=null!;publicBloggingContext(DbContextOptions<BloggingContext>options):base(options){}protectedoverridevoidOnModelCreating(ModelBuildermodelBuilder){modelBuilder.HasDefaultSchema("MySchema");}}}
Using this I've diagnosed the issue and the two below are contributing:
index name lengths are limited to 64 chars in Postgres
the schema name is missing when the index is attempted to be deleted
I've also got a solution for this and would love to raise a PR but sharing here first as per the contributing guidelines.
The text was updated successfully, but these errors were encountered:
First of thank you for all the great work you guys do on this library.
So the issue I've experienced is using the
BulkInsertOrUpdateAsync
extension method and supplying update properties in theBulkConfig
. When executed the action fails with the below error:I've created the below small program that replicates the issue:
Using this I've diagnosed the issue and the two below are contributing:
I've also got a solution for this and would love to raise a PR but sharing here first as per the contributing guidelines.
The text was updated successfully, but these errors were encountered: