我正在尝试按照以下示例在我的数据库中进行插入: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。
最佳答案
DEFAULT_VALUES
和 ROW_COUNT
位于 SQL Server 中,而不是 MySQL 或 MariaDB 中。您的 Entity Framework 配置需要更改。
关于c# - Entity Framework 和 MariaDB - phpMyAdmin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40323931/