Pomelo.EntityFrameworkCore.MySql: Unknown column 'GENERATION_EXPRESSION' in 'field list'

Steps to reproduce

I tried to scaffold a mysql table.

The issue

scaffolding the table didnt work and threw the following error:

MySql.Data.MySqlClient.MySqlException (0x80004005): Unknown column 'GENERATION_EXPRESSION' in 'field list'
 ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Unknown column 'GENERATION_EXPRESSION' in 'field list'
   at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in /_/src/MySqlConnector/Core/ResultSet.cs:line 51
   at MySql.Data.MySqlClient.MySqlDataReader.ActivateResultSet() in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlDataReader.cs:line 130
   at MySql.Data.MySqlClient.MySqlDataReader.CreateAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, IDictionary`2 cachedProcedures, IMySqlCommand command, CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlDataReader.cs:line 391
   at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(IReadOnlyList`1 commands, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/CommandExecutor.cs:line 62
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlCommand.cs:line 210
   at Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal.MySqlDatabaseModelFactory.GetColumns(DbConnection connection, IReadOnlyList`1 tables, Func`3 tableFilter)
   at Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal.MySqlDatabaseModelFactory.GetTables(DbConnection connection, Func`3 filter)
   at Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal.MySqlDatabaseModelFactory.Create(DbConnection connection, DatabaseModelFactoryOptions options)
   at Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal.MySqlDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Unknown column 'GENERATION_EXPRESSION' in 'field list'

Further technical details

MySQL version: 5.1.38-community Operating system: Windows Server 2012 Pomelo.EntityFrameworkCore.MySql version: i have tried all versions Microsoft.AspNetCore.App version: tried 5.0 and 3.1

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21

Most upvoted comments

The backport will be part of 3.2.7. Use the latest 3.2 nightly build until then.

its 5.1.38-community

That is the issue. MySQL is complaining, that we use the GENERATION_EXPRESSION field of the INFORMATION_SCHEMA.COLUMNS table/view.

That should be supported in MySQL 5.7, which is the lowest version that we officially support.

Support for MySQL 5.1 from Oracle ended 8.5 years ago on 2013-12-31 (from MySQL Product Support EOL Announcements: MySQL 5.1 covered under Oracle Lifetime Sustaining Support):

December 4, 2013

MySQL 5.1 covered under Oracle Lifetime Sustaining Support

Per Oracle’s Lifetime Support policy, as of December 31, 2013, MySQL 5.1 is covered under Oracle Sustaining Support.

Users are encouraged to upgrade to MySQL 5.6.

So you need to upgrade your database server, if you want to use it with Pomelo.

You are right. Just saw it as closed under 3.2.6 milestone and thought it was merged.

Probably not worth it, but I guess we could substitute GENERATION_EXPRESSION w/ NULL AS GENERATION_EXPRESSION for version < 5.7

https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/6aac749dc0190cd16e3869f05dee4694eafdf75f/src/EFCore.MySql/Scaffolding/Internal/MySqlDatabaseModelFactory.cs#L259