elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.26k stars 1.14k forks source link

Exception Occurred After Upgrading to .NET CORE 8 with Microsoft SQL Server 2017 #5942

Open yunlan365 opened 3 weeks ago

yunlan365 commented 3 weeks ago

Hello, I am using version v2.14.1 of the code, and after upgrading to .NET CORE 8, an exception occurred. I am using Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64). The code works fine when I remove the database and use the default storage. Can you help me figure out the reason? I have attached the code, thank you!

Specifically, the error occurs when I delete or publish a workflow.

image

YunLanCrm.WebApiTest.zip

sfmskywalker commented 3 weeks ago

It's hard to say what's causing this without also seeing the data and a debugger attached to the process for full context. Perhaps you can try by cloning the source code for 2.x, replace the package references to Elsa with project references, and run it in the debugger?

yunlan365 commented 2 weeks ago

I added tracing code to print the SQL in the source code and found that the issue is here. The SQL statement seems to have a problem during parsing, which causes the execution to prompt: "Incorrect syntax near '$'."

@sfmskywalker

image

yunlan365 commented 2 weeks ago

I found the root cause of the issue. After modifying the database compatibility level, it worked.

ALTER DATABASE your_database_name SET COMPATIBILITY_LEVEL = 130;

The issue was that it was not compatible with the OPENJSON function.