Incorrect SQL generated by Pomelo with MySQL and .NET Core

.net-core c# entity-framework-core mysql


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']
2019-09-16T12:36:49.9249074-07:00 0HLPQRKH27D40 [ERR] An exception occurred in the database while saving changes.
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.

9/17/2019 3:41:56 AM

Accepted Answer

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.

11/27/2019 4:00:16 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow