AbpAuditLogs (Update-Database) : 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,
See original GitHub issueenv: ABP v3.8.1 .Net Core 2.1.0
StackTrace:
PM> update-database
Applying migration ‘20180821092341_Init’.
Failed executing DbCommand (5ms) [Parameters=[], CommandType=‘Text’, CommandTimeout=‘30’]
CREATE TABLE AbpAuditLogs
(
Id
bigint NOT NULL AUTO_INCREMENT,
TenantId
int NULL,
UserId
bigint NULL,
ServiceName
varchar(256) NULL,
MethodName
varchar(256) NULL,
Parameters
varchar(1024) NULL,
ExecutionTime
datetime(6) NOT NULL,
ExecutionDuration
int NULL,
ClientIpAddress
varchar(64) NULL,
ClientName
varchar(128) NULL,
BrowserInfo
varchar(512) NULL,
Exception
varchar(2000) NULL,
ImpersonatorUserId
bigint NULL,
ImpersonatorTenantId
int NULL,
CustomData
varchar(2000) NULL,
CONSTRAINT PK_AbpAuditLogs
PRIMARY KEY (Id
)
);
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,
ExecutionDuration
int NULL,
ClientIpAddress
varchar(’ at line 8
Step:
- download sample from ABP website, selected “.net core” & “EF”
- modify database from sql server to mysql. a. modify connection string in appsettings.json jin Web.Host project. b. modify “UseSqlServer” to “UseMySql” in **DbContextConfigurer class file. c. delete migrations files in Migrations directory. d. add reference “Pomelo.EntityframeworkCore.Mysql” v2.1.1 in Web.Host & EntityFrameworkCore project.
- input command “Add-Migration” in Package Manager Console
- input command “Update-Database” in Package Manager Console
Summary:
database-code-first create C# “DateTime” type to “datetime(6)” in migration class。
ExecutionTime = table.Column<DateTime>(nullable: false),
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
Solution: add mysqlOption to UseMySql funtion.
The final code like this:
hi @muzizongheng
I didn’t use mysql in my project. You can see from the error message that this problem is EFCore+Mysql.
You can check if there is a solution at https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql.