Bug #110126 Incorrect datetime value - MySQL 8.0.32 - Entity framework
Submitted: 19 Feb 2023 10:40 Modified: 14 Apr 2023 11:15
Reporter: Matasci Sacha Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:8.0.32 OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[19 Feb 2023 10:40] Matasci Sacha
Description:
In a c# code, I'm using MySql.Data.EntityFramework.
After upgrading from 8.0.31 to 8.0.32 it comes an exception.
On db nothing is changed. If a get back to 8.0.31 all work well.

Incorrect datetime value: '0001-01-01 00:00:00' for column 'updatetime' at row 1

Eccezione generale
==================
An error occurred while updating the entries. See the inner exception for details.

   in System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
   in System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<>c.<Update>b__21_0(UpdateTranslator ut)
   in System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func`2 updateFunction)
   in System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update()
   in System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__153_0()
   in System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   in System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
   in System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass148_0.<SaveChangesInternal>b__0()
   in System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
   in System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
   in System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)
   in System.Data.Entity.Core.Objects.ObjectContext.SaveChanges()
   in DBEntityLayer.DBModelEntity.Common.DBExecutor.registraOperazioniEseguite(BAEntities dbcontext, List`1 result) in D:\Versioni_Sigest\SIGest\DBEntityLayer\DBModelEntity\Common\DBExecutor.cs:riga 265
   in DBEntityLayer.DBModelEntity.Common.DBExecutor.eseguiOperazioni(List`1 listaOperazioni) in D:\Versioni_Sigest\SIGest\DBEntityLayer\DBModelEntity\Common\DBExecutor.cs:riga 187
   in TFClient.BusinessLogicService.Common.DatabaseService.eseguiOperazioni(List`1 listaOperazioni) in D:\Versioni_Sigest\SIGest\TFClient\BusinessLogicService\Common\DatabaseService.cs:riga 33

Eccezione interna
=================
Incorrect datetime value: '0001-01-01 00:00:00' for column 'datainserimento' at row 1

   in MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   in MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   in MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
   in MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   in MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   in MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   in MySql.Data.EntityFramework.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   in System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   in System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<>c.<Reader>b__6_0(DbCommand t, DbCommandInterceptionContext`1 c)
   in System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   in System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
   in System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
   in System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   in System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
   in System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()

How to repeat:
                // Initialize the connection string builder for the
                // underlying provider.
                var sqlBuilder = new MySqlConnectionStringBuilder
                {
                    Server = "host",
                    Database = "db",
                    UserID = "username",
                    Password = "password",
                    Port = 3306,
                    SslMode = MySqlSslMode.Disabled,
                    AllowZeroDateTime = true,
                    ConvertZeroDateTime = true,
                    PersistSecurityInfo = true
                };

                // Initialize the EntityConnectionStringBuilder.
                var entityBuilder = new EntityConnectionStringBuilder
                {
                    Provider = "MySql.Data.MySqlClient",
                    ProviderConnectionString = sqlBuilder.ToString(),
                    Metadata = @"res://*/DBModelEntity.DBModel.csdl|res://*/DBModelEntity.DBModel.ssdl|res://*/DBModelEntity.DBModel.msl"
                };

                _entityconnessione = new EntityConnection(entityBuilder.ToString());

Suggested fix:
Come back to a working solution like in 8.0.31.
[19 Feb 2023 10:56] Matasci Sacha
Title change
[13 Mar 2023 18:50] Matasci Sacha
Any news?
[14 Mar 2023 11:15] MySQL Verification Team
Hello Matasci Sacha,

Thank you for the bug report.
Could you please provide a complete test case and code file which hit the issue reported along with the table that has column 'datainserimento'? Thanks.

Regards,
Ashwini Patil
[15 Apr 2023 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".