I've been using .NET Core and Pomelo.EntityFrameworkCore.MySql (v1.1.2, it is not the latest but I would prefer to stay on it for various reasons).
I was doing some refactoring of the model classes, creating a child-parent relationship (eg. Order has a Customer) and now when I run my project I get an exception
2019-09-16T12:36:49.8158085-07:00 0HLPQRKH27D40 [INF] Executed DbCommand (6ms) [Parameters=[],
CommandType='Text', CommandTimeout='0']
INSERT INTO `Order`
DEFAULT VALUES;
SELECT LAST_INSERT_ID(); (6438bdd5)
2019-09-16T12:36:49.9249074-07:00 0HLPQRKH27D40 [ERR] An exception occurred in the database while saving changes.
(3b5ca34b)
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> MySql.Data.MySqlClient.MySqlException: 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 'DEFAULT VALUES;
The problem seems to be the use of default values
in insert into 'order' default values;
because MySQL doesn't support that syntax. My dev version of mysql is 5.1, but that doesn't seem to matter since it doesn't seem to be in later versions.
I looked (naively) at the Pomelo source but only found usage of "DEFAULT VALUES" in a unit test.
I was mapping properties in Order to another object's properties, eg
public string PropA => obj.ProbA
and when I stopped doing that and changed it to long form using getters and setters it started working.