Bug #103557 ef core linq sum cast error
Submitted: 3 May 2021 8:22 Modified: 19 May 2021 12:50
Reporter: Lee Han Yeol Lee Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:5.0.3 OS:Windows
Assigned to: CPU Architecture:Any

[3 May 2021 8:22] Lee Han Yeol Lee
Description:
using database version mysql 5.7.28

but linq to sql query

from data in context.Table_A
where data.userID == userID
group data by data.grade into g
select new { value = g.Sum(x => x.grade) };

SELECT COALESCE(SUM(CAST(`u`.`grade` AS int)), 0) AS `value`
FROM `Table_A` AS `u`
WHERE `u`.`userID` = @__userID_0
GROUP BY `u`.`grade`

exception: MySql.Data.MySqlClient.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

mysql 5.7.28 not supported int

How to repeat:
using database version mysql 5.7.28

but linq to sql query

from data in context.Table_A
where data.userID == userID
group data by data.grade into g
select new { value = g.Sum(x => x.grade) };

SELECT COALESCE(SUM(CAST(`u`.`grade` AS int)), 0) AS `value`
FROM `Table_A` AS `u`
WHERE `u`.`userID` = @__userID_0
GROUP BY `u`.`grade`

exception: MySql.Data.MySqlClient.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

mysql 5.7.28 not supported int
[19 May 2021 12:50] MySQL Verification Team
Hello,

Thank you for the bug report.
Imho this is duplicate of Bug #73054, please see Bug #73054.

Regards,
Ashwini Patil