【发布时间】:2016-10-29 21:37:49
【问题描述】:
我正在尝试按照以下示例在我的数据库中插入:http://insidemysql.com/howto-starting-with-mysql-ef-core-provider-and-connectornet-7-0-4/。我成功创建了数据库和表,但是由于某种原因,我在下面的 INSERT 上不断收到相同的错误:
var entry = new Sistema();
using (var context = SistemaFactory.Create(connectionString))
{
context.Sistemas.Add(entry);
context.SaveChanges();
}
这是我的模型:
public class Sistema
{
public int Id { get; set; }
public List<Agenda> Agendas { get; set; }
}
还有我不断收到的错误:
{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 MariaDB server version for the right syntax to use near 'DEFAULT VALUES;
SELECT `Id`
FROM `Sistemas`
WHERE ROW_COUNT() = 1
AND `Id`=' at line 2
到目前为止,我无法修复此错误,因此我使用的是 PostgreSQL 而不是 MySQL。
【问题讨论】:
-
向我们展示产生错误的 SQL。
-
@RickJames 我不知道它是否可能,我能得到的唯一 SQL 已经在问题上了。
-
我们需要看到“第 1 行”。 (有时第 3 方软件会妨碍您!)
-
@RickJames Visual Studio 只显示这个查询:DEFAULT VALUES;选择
IdFROMSistemasWHERE ROW_COUNT() = 1 ANDId= -
@RickJames 当我在 phpMyAdmin 上尝试此查询时,它会在“DEFAULT VALUES”行返回错误。
标签: c# mysql entity-framework asp.net-core mariadb