The problem is caused by the '{'
and '}'
symbols inside SQL string, because in ExecuteSqlRaw{Async}
they are used to specify parameter placeholders, so the string should be a valid input for string.Format
function. In fact EF Core implementation uses string.Format
(even though you don't pass parameters) at some point, which in turn generates the exception in question. Which can be seen if you do
string.Format(query);
The solution is to make it valid format string by doubling '{'
and '}'
symbols inside. For instance, in your sample:
string query = "update mytable set column1 = 100, column2= '[{{"property1":"value1","property2":null}}]' where condition;update mytable set column1= 200, column2= '[{{"property1":"value2","property":null}}]' where condition;"
Also it would be good if you try actually parameterizing your SQL.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…