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
Fails when BulkDelete more than one Db Class object.
The object fails equally whether it is a value read from the DB or a randomly generated value. I debugged and verified that all properties of the entitiesToDelete object are fine.
I have identified the cause of the failure as when PK and unique key are present together in the DB.
Currently, pk is set on the 'id' column which is long, auto increment, and the unique key is set on the name column which is string.
The bulk delete is executed normally if I remove the unique key of the 'name' column.
In the same environment, BulkInsert/BulkUpdate works fine.
Example:
await context.BulkDeleteAsync(entitiesToDelete, cancellationToken: ct);
StackTrace:
MySqlConnector.MySqlException (0x80004005): 2 rows were copied to table_nameTemp5c0673f5 but only 1 was inserted. at MySqlConnector.MySqlBulkCopy.WriteToServerAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in //src/MySqlConnector/MySqlBulkCopy.cs:line 347 at MySqlConnector.MySqlBulkCopy.WriteToServerAsync(DataTable dataTable, CancellationToken cancellationToken) in //src/MySqlConnector/MySqlBulkCopy.cs:line 148 at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, Action1 progress, Boolean isAsync, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, Action1 progress, Boolean isAsync, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, Action1 progress, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, OperationType operationType, Action1 progress, Boolean isAsync, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, OperationType operationType, Action1 progress, Boolean isAsync, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, OperationType operationType, Action1 progress, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlBulkOperation.MergeAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, OperationType operationType, Action1 progress, CancellationToken cancellationToken) at EFCore.BulkExtensions.DbContextBulkTransaction.ExecuteAsync[T](DbContext context, Type type, IEnumerable1 entities, OperationType operationType, BulkConfig bulkConfig, Action1 progress, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__81.<b__8_0>d.MoveNext()
`
To Reproduce
Table with column 'A' that is long, auto-increment, pk and column 'B' that is string, unique key, when bulk-delete with 2 or more corresponding table objects: Failed.
Afterward, delete the unique key from column 'B' and it works fine.
I tried inserting an index as well, and the BulkDelete method works fine. The problem seems to be with the unique key.
Expected behavior
DB objects with the same PK as a given set of objects are deleted normally.
Technical details (please complete the following information):
Database server version: [MariaDB 11.6.2]
Operating system: [Windows 10]
Other technical details: [ASP.NET Core 9.0.2, efcore.bulkextensions.mysql\9.0.0-rc.1, mysqlconnector\2.4.0, Pomelo.EntityFrameworkCore.MySqlPomelo.EntityFrameworkCore.MySql, 9.0.0-preview.3.efcore.9.0.0]
Additional context
It is difficult to determine if this is an issue with mysqlconnector or ef core. If it's a problem with another package, I'll open an issue there.
The text was updated successfully, but these errors were encountered:
Describe the bug
Fails when BulkDelete more than one Db Class object.
The object fails equally whether it is a value read from the DB or a randomly generated value. I debugged and verified that all properties of the entitiesToDelete object are fine.
I have identified the cause of the failure as when PK and unique key are present together in the DB.
Currently, pk is set on the 'id' column which is long, auto increment, and the unique key is set on the name column which is string.
The bulk delete is executed normally if I remove the unique key of the 'name' column.
In the same environment, BulkInsert/BulkUpdate works fine.
Example:
await context.BulkDeleteAsync(entitiesToDelete, cancellationToken: ct);
StackTrace:
MySqlConnector.MySqlException (0x80004005): 2 rows were copied to table_nameTemp5c0673f5 but only 1 was inserted. at MySqlConnector.MySqlBulkCopy.WriteToServerAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in //src/MySqlConnector/MySqlBulkCopy.cs:line 347 at MySqlConnector.MySqlBulkCopy.WriteToServerAsync(DataTable dataTable, CancellationToken cancellationToken) in //src/MySqlConnector/MySqlBulkCopy.cs:line 148 at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, Action1 progress, Boolean isAsync, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, Action1 progress, Boolean isAsync, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, Action1 progress, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, OperationType operationType, Action1 progress, Boolean isAsync, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, OperationType operationType, Action1 progress, Boolean isAsync, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlAdapters.MySql.MySqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, OperationType operationType, Action1 progress, CancellationToken cancellationToken) at EFCore.BulkExtensions.SqlBulkOperation.MergeAsync[T](DbContext context, Type type, IEnumerable1 entities, TableInfo tableInfo, OperationType operationType, Action1 progress, CancellationToken cancellationToken) at EFCore.BulkExtensions.DbContextBulkTransaction.ExecuteAsync[T](DbContext context, Type type, IEnumerable1 entities, OperationType operationType, BulkConfig bulkConfig, Action1 progress, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__81.<b__8_0>d.MoveNext()
`
To Reproduce
Table with column 'A' that is long, auto-increment, pk and column 'B' that is string, unique key, when bulk-delete with 2 or more corresponding table objects: Failed.
Afterward, delete the unique key from column 'B' and it works fine.
I tried inserting an index as well, and the BulkDelete method works fine. The problem seems to be with the unique key.
Expected behavior
DB objects with the same PK as a given set of objects are deleted normally.
Technical details (please complete the following information):
Database server version: [MariaDB 11.6.2]
Operating system: [Windows 10]
Other technical details: [ASP.NET Core 9.0.2, efcore.bulkextensions.mysql\9.0.0-rc.1, mysqlconnector\2.4.0, Pomelo.EntityFrameworkCore.MySqlPomelo.EntityFrameworkCore.MySql, 9.0.0-preview.3.efcore.9.0.0]
Additional context
It is difficult to determine if this is an issue with mysqlconnector or ef core. If it's a problem with another package, I'll open an issue there.
The text was updated successfully, but these errors were encountered: