Reputation: 61
I am getting the below exception while connecting to the database server.
Exception: An error occurred while executing the command definition. See the inner exception for details.
StackTrace: at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Lorax.DataModel.GenericRepository.GenericRepository`1.GetAll()
at LoraxQueueConsumer.LoraxScheduler.CheckDB_Conn() in D:\Lorax\AthenaQueueConsumer\LoraxScheduler.cs:line 154
Inner Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at MySql.Data.MySqlClient.CharSetMap.GetCharacterSet(DBVersion version, String CharSetName)
at MySql.Data.MySqlClient.MySqlField.SetFieldEncoding()
at MySql.Data.MySqlClient.NativeDriver.GetColumnData(MySqlField field)
at MySql.Data.MySqlClient.NativeDriver.GetColumnsData(MySqlField[] columns)
at MySql.Data.MySqlClient.Driver.GetColumns(Int32 count)
at MySql.Data.MySqlClient.ResultSet.LoadColumns(Int32 numCols)
at MySql.Data.MySqlClient.ResultSet..ctor(Driver d, Int32 statementId, Int32 numCols)
at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlDataReader.Close()
at MySql.Data.MySqlClient.MySqlCommand.ResetReader()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
Source: System.Data.Entity
Below is the configuration used:
With DB Version 8.0.28, I was not getting the above exception. Everything was working fine.
I have tried adding charset=utf8mb3;
in the connection string but still getting the exception.
Upvotes: 0
Views: 367
Reputation: 28162
This is a known bug in older versions of MySql.Data that occurs after upgrading your server to MySQL Server 8.0.29 or later: https://bugs.mysql.com/bug.php?id=107259
You need to update to MySql.Data v8.0.30 or later.
Upvotes: 0