question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

env: 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:

  1. download sample from ABP website, selected “.net core” & “EF”
  2. 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.
  3. input command “Add-Migration” in Package Manager Console
  4. 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:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
muzizonghengcommented, Aug 22, 2018

Solution: add mysqlOption to UseMySql funtion.

The final code like this:


  public static class XXXContextConfigurer
    {
        public static void Configure(DbContextOptionsBuilder<SCDbContext> builder, string connectionString)
        {
            //
            builder.UseMySql(connectionString, 
                mySqlOptionsAction => mySqlOptionsAction.ServerVersion(new Version(), ServerType.MySql));
        }

        public static void Configure(DbContextOptionsBuilder<SCDbContext> builder, DbConnection connection)
        {
            //
            builder.UseMySql(connection);
        }
    }
2reactions
malimingcommented, Aug 22, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

You have an error in your SQL syntax; check the manual ...
This error comes when you have a column that is one of the MySQL keywords. Try to run your queries with all of...
Read more >
MySQL 1064 Error: You have an error in your SQL syntax
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to...
Read more >
SQL Error 1064: A Beginner's Guide to Fixing the Error
Don't let syntax errors derail your SQL queries! Learn all you need to know about SQL error 1064 and how to fix it...
Read more >
MySQL 8.0 Reference Manual :: 13.2.17 UPDATE Statement
UPDATE is a DML statement that modifies rows in a table. An UPDATE statement can start with a WITH clause to define common...
Read more >
Chapter 2 Server Error Message Reference
Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found