EntityFramework-Extensions icon indicating copy to clipboard operation
EntityFramework-Extensions copied to clipboard

BulkMergeAsync throws generic exception when auditing with MySQL

Open scottiemc7 opened this issue 2 years ago • 3 comments

Description

EFE throws a generic exception when using option UseAudit = true with BulkMergeAsync.

Exception

System.Exception: Error: 0029: Oops! A general error has occurred. Please report the issue including the stack trace to our support team: [email protected].

at .( , DbCommand )
   at .Execute(List`1 actions)
   at Z.BulkOperations.BulkOperation.Execute()
   at Z.EntityFramework.Extensions.EntityBulkOperation`1.BulkMerge()
   at .BulkMerge[T](BulkOperation`1 this, DbContext context, List`1 list, Boolean isManager, Type type, String typeName)
   at .`1.(SchemaEntityType )
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at .BulkMerge[T](DbContext this, BulkOperation`1 bulkOperation, IEnumerable`1 entities2)
   at DbContextExtensions.BulkMerge[T](DbContext this, IEnumerable`1 entities, Action`1 bulkOperationFactory)
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at DbContextExtensions.`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

Fiddle or Project (Optional)

https://bitbucket.org/visiondatabasesystems/efe-testing/src/main/

Further technical details

  • EF version: EF6
  • EF Extensions version: 6.14.3
  • Database Provider: MySQL

Thank you for looking into this!

scottiemc7 avatar Aug 04 '22 19:08 scottiemc7

Hello @scottiemc7 ,

Thank you for reporting,

Unfortunately, this is a scenario that we currently don't support.

I will look with my employee to evaluate the effort next Monday, but meanwhile, the only solution would be not using the Audit feature

Best Regards,

Jon

JonathanMagnan avatar Aug 05 '22 14:08 JonathanMagnan

OK great, thank you. This is critical for us, so if using the Audit feature with MySQL is not possible please let me know.

scottiemc7 avatar Aug 05 '22 17:08 scottiemc7

Hello @scottiemc7 ,

Unfortunately, after discussion with my employees, it will not be done right now.

We currently focus mainly on re-writing our code at this moment to support correctly EF Core 7, but this request is currently asking us for more modifications than we initially expected.

JonathanMagnan avatar Aug 10 '22 15:08 JonathanMagnan

Ok thank you.

scottiemc7 avatar Aug 15 '22 22:08 scottiemc7

Is there any progress on this issue? I use the latest version and still have this exception error. EF version: EntityFrameworkCore 7.0.9 EF Extensions version: 7.22.4 Database Provider: MySQL 8.0.31

LEIRONGHUA avatar Jul 18 '23 01:07 LEIRONGHUA

Hello @LEIRONGHUA ,

Unfortunately, this scenario is still unsupported for MySQL.

There is no either any short term plan to make it compatible at this moment.

JonathanMagnan avatar Jul 18 '23 15:07 JonathanMagnan

Hi @JonathanMagnan thanks for your answer。 Please tell me what is the difficulty? What should I do if I want to contribute my own code? Because I have tested, the UseAudit of MySql can work normally in BulkInsertAsync and BulkUpdateAsync.

LEIRONGHUA avatar Jul 19 '23 05:07 LEIRONGHUA

I will come back to you with the answer next week. I just need to confirm with my developer if what I will say is right. Perhaps it's good news but I need to confirm with him first.

JonathanMagnan avatar Jul 19 '23 14:07 JonathanMagnan

Hello @LEIRONGHUA ,

Unfortunately, I was wrong.

At this moment, we will put this request in our backlog as this is definitely something we want to investigate and be compatible. But unfortunately, that is currently impossible with our current project during the summer.

So I hope that it will be something we will be able to look at in September.

Best Regards,

Jon

JonathanMagnan avatar Jul 28 '23 15:07 JonathanMagnan

Hello @JonathanMagnan

Excuse me, is there any latest progress on this issue?

Best Regards,

Lei

LEIRONGHUA avatar Sep 08 '23 09:09 LEIRONGHUA

Hello @LEIRONGHUA ,

Unfortunately, I was wrong.

At this moment, we will put this request in our backlog as this is definitely something we want to investigate and be compatible. But unfortunately, that is currently impossible with our current project during the summer.

So I hope that it will be something we will be able to look at in September.

Best Regards,

Jon

Hello @JonathanMagnan

Excuse me, is there any latest progress on this issue?

Best Regards,

Lei

LEIRONGHUA avatar Nov 01 '23 01:11 LEIRONGHUA

Hello @LEIRONGHUA ,

Sorry for the delay. I forget you answer you last time.

For most cases, our library support is now auditing for MySQL but not perfectly.

All basic cases of:

should be supported with the most common options.

However, the BulkSynchronize and some more advanced options that affect if a row is updated or not (the row matches, but you can still ignore the update), such as UpdateMatchedAndConditionExpression are not supported at this moment.

If you find an issue with a common option, let us know.

Best Regards,

Jon

JonathanMagnan avatar Nov 02 '23 18:11 JonathanMagnan

Hello @JonathanMagnan ,

In the BulkMergeAsync method of MySql, operation.UseAudit=true will cause an exception.

But in BulkInsertAsync and BulkUpdateAsync, it works normally.

Please solve this problem, it will be of great help for auditing using MySql database.

System.Exception
Error: 0029: Oops! A general error has occurred. Please report the issue including the stack trace to our support team: [email protected] , v=7.100.0.5.
   at .( , DbCommand )
   at .( , DbCommand )
   at .Execute(List`1 actions)
   at .(List`1 )
   at Z.BulkOperations.BulkOperation.Execute()
   at Z.BulkOperations.BulkOperation.BulkMerge()
   at .BulkMerge[T](DbContext this, IEntityType entityType, IEnumerable`1 list, Action`1 options, SavingSelector savingSelector, Boolean forceSpecificTypeMapping)
   at .BulkMerge[T](DbContext this, IEnumerable`1 entities, Action`1 options, Boolean isBulkSaveChanges)
   at DbContextExtensions.BulkMerge[T](DbContext this, IEnumerable`1 entities, Action`1 options)
   at DbContextExtensions.`1.()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at DbContextExtensions.BulkMergeAsync[T](DbContext this, IEnumerable`1 entities, Action`1 options, CancellationToken cancellationToken)

LEIRONGHUA avatar Nov 08 '23 12:11 LEIRONGHUA

Hello @LEIRONGHUA ,

Sorry, I got a misunderstanding with my employee about what was supported for the Audit with MySQL.

I will have a discussion with him next Monday to better understand why basic scenario without an identity is not yet supported.

JonathanMagnan avatar Nov 09 '23 19:11 JonathanMagnan

Hello @LEIRONGHUA ,

The v8.101.1.0 has been released.

We should now support additional scenarios, such as when the key is not an identity.

Let me know if everything works on your side now.

Best Regards,

Jon

JonathanMagnan avatar Nov 29 '23 19:11 JonathanMagnan

Hello @JonathanMagnan Auditing in MySQL now works properly, which helped me solve a big problem. Thank you very much!

LEIRONGHUA avatar Dec 22 '23 14:12 LEIRONGHUA

Hello again,

Great to hear everything is working as expected.

Don't hesitate to contact us if you need further assistance.

Best regards, Jon

JonathanMagnan avatar Dec 22 '23 15:12 JonathanMagnan