Bug #84012 Exception caused by Code First Migrations-have an error in your SQL syntax
Submitted: 30 Nov 2016 4:15 Modified: 10 Aug 2022 17:30
Reporter: Charlie Chu (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:7.0 OS:Any
Assigned to: Assigned Account CPU Architecture:Any

[30 Nov 2016 4:15] Charlie Chu
Description:
I’m trying to use EF Code First Migrations to add a new field to the model and migrate that change to MySQL database. I’m getting the exception.

Exception message:

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 '/1/1 ??12:00:00' at line 1

Stack trace:

```csharp
MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MyS
QL server version for the right syntax to use near '/1/1 ??12:00:00' at line 1
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, String ex
ecuteMethod, IReadOnlyDictionary`2 parameterValues, Boolean openConnection, Boolean closeConnection)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalConnection connection, I
ReadOnlyDictionary`2 parameterValues, Boolean manageConnection)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCo
mmands, IRelationalConnection connection)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Tools.Cli.DatabaseUpdateCommand.<>c__DisplayClass0_0.<Configure>b__0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args)
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 '/1/1 ??12:00:00' at line 1
```

How to repeat:

Steps to reproduce:

1. I added a `public DateTime BirthDate` new property to the model.
2. enter command: `dotnet ef migrations add NewField_BirthDate`.
3. enter command: `dotnet ef database update`.
4. get the exception.

In `Migrations` folder on my project, `BirthDate` defaultValue is DateTime(1,1,1,0,…) in `Up` method.
[2 Dec 2016 5:43] Chiranjeevi Battula
Hello Charlie,

Thank you for the bug report.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.
[10 Aug 2022 17:30] Daniel Valdez
Can't reproduce the issue. Please use our latest release, Connector/NET v8.0.30.