This article is to discuss the support problem of Efcore to MySQL.
The ORM used in this article is MySql.Data.EntityFrameworkCore 6.10. Version 6
There is a table in the system: Crm.contacts contains the first_name and last_name two fields
In general, when you need queries, you need to concatenate the two fields together for a fuzzy query
MySQL supported SQL statements for SELECT * from ' crm.contacts ' where concat (first_name, last_name) like concat ('% ', ' abc ', '% ')
If you are using DbContext in your program. Crmcontacts.where (s = = (S.firstname + s.lastname). Contains ("abc")),
The SQL statement parsed out by Nero profile SQL intercepts the ORM framework for SELECT * from ' crm.contacts ' where first_name+ last_name like concat ('% ', ' abc ', '% ' )
MySQL does not support the above SQL statements
If you are using DbContext in your program. Crmcontacts.where (s) = string. Contat (S.firstname + s.lastname). Contains ("abc")),
The SQL statement parsed by Nero profile SQL intercepted by the ORM framework is select * from ' crm.contacts '
ORM gets all the contents of the table in memory for querying
But in Sqlserve, select * FROM [crm.contacts] where first_name+ last_name like '%abc% ' can be parsed so there is no such problem
About Efcore support for MySQL multi-field stitching query