【发布时间】:2020-10-24 18:17:59
【问题描述】:
将 Mysql 与 dotnet 核心 API 结合使用,我的实体具有 DateTime 类型列。在迁移中,它得到一个错误
MySql.Data.MySqlClient.MySqlException (0x80004005): 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 '(6) NOT NULL,
`ModifiedAt` datetime(6) NOT NULL,
【问题讨论】:
-
首先,上传您的完整
CREATE代码。 -
我认为您的迁移器正在尝试创建您的 mysql 版本无法处理的数据类型规范。这可能是迁移器中的错误/缺乏支持,您必须使用任何选项将原始/自定义类型传递给数据库。你的 MySQL 是什么版本
-
我的服务器版本:5.5.51-38.1,包:
我的实体代码:namespace Core.Entities { public class Materials:BaseEntity { public string Name { get;放; } 公共日期时间 CreatedAt { 获取;放; } public DateTime ModifiedAt { get;放; } 公共布尔状态 { 获取;放; } } } 我的 CLICMD:dotnet ef migrations add MaterialsAdded -p Infrastructure -s API -o Data/Migrations
标签: c# mysql .net-core migration pomelo-entityframeworkcore-mysql