Error Updating TiDB 6.5.3 Database Entity Model with .NET EF Framework (No Issues with Version 4.0.15)

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: .net的ef框架更新tidb6.5.3数据库实体模型报错(4.0.15版本没有问题)

| username: Cloud王

To improve efficiency, please provide the following information. A clear problem description can help resolve the issue faster:

[Overview] Scenario + Problem Overview
Using the .NET EF framework to operate TiDB 6.5.3 results in an error (no issues with version 4.0.15):

[Application Framework and Development Adaptation Business Logic]
.NET EF framework

[Problem] Current Issue Encountered
Operation: Using the .NET EF framework to connect to TiDB 6.5.3 and update the database entity model
Error message: Unable to generate model: “System.ArgumentException: An item with the identifier ‘Id’ already exists in the metadata collection”

[Business Impact]
Unable to use the .NET EF framework

[TiDB Version]
6.5.3

| username: Icemap | Original post link

Hello, is there more detailed logs available for reference? For example, what SQL was actually executed, or what error messages were returned by TiDB.

| username: hey-hoho | Original post link

Please provide the code where the error occurs and the detailed error message, as well as which database driver you are using.

| username: Cloud王 | Original post link

There are no more detailed error logs :joy:

| username: Cloud王 | Original post link

This is the error content.

| username: redgame | Original post link

Please check the EF configuration to ensure compatibility with TiDB 6.5.3. You may need to update or adjust some EF configuration options to accommodate the new version of TiDB.

| username: hey-hoho | Original post link

It looks like you’re generating an EDM model from the database. Try deleting all the existing models and resynchronizing.

| username: Cloud王 | Original post link

Deleting and recreating doesn’t work either. I even set up a brand new TiDB 6.5.3 environment and generated a new model, but it still doesn’t work. :sob:

| username: Cloud王 | Original post link

Which configurations need special attention to be compatible with TiDB 6.5.3? :handshake:

| username: hey-hoho | Original post link

Check which model is reporting the error, and send the result of the show create table command.

| username: Cloud王 | Original post link

All tables report errors. Even creating a very simple table, such as create table test(id int), results in an error. The error message indicates that the metadata for the table already exists, but in reality, this is a newly created table, so it shouldn’t exist…

| username: Cloud王 | Original post link

We created versions 4.0.15 and 6.5.3 in the test environment, then enabled audit logs, and after capturing SQL, we found the cause:

select * from
(select 6 id from INFORMATION_SCHEMA.`COLUMNS` where table_schema = 'test') t
where t.id = 1;

This SQL statement, when there are tables under the test database, returns an empty result in TiDB 4.0.15, which is the correct result. However, in TiDB 6.5.3, the query result is not empty, which is incorrect.

If we switch to INFORMATION_SCHEMA.TABLES, this issue does not occur.

After checking the explain plan, the above SQL in TiDB 6.5.3 uses MemTableScan:
image

But in TiDB 4.0.15, or when switching to the INFORMATION_SCHEMA.TABLES table, the execution plan uses TableDual:
image

Could this be a bug?

| username: zhouzeru | Original post link

Based on this error message, it is possible that there is already a column named “Id” in the data table, and the EF framework is trying to add a column with the same name to the metadata, causing a conflict.

To resolve this issue, you can try the following steps:

  1. Check the table structure: Inspect the structure of the relevant data table in the TiDB database to confirm whether there is a column named “Id”. If it does not exist, you can rule out this issue. If it does exist, you need to further check whether there is a property with the same name in the EF framework entity class.
  2. Check the EF entity class: Check whether there is a property named “Id” in the EF framework entity class. If there is, confirm whether this property corresponds to the “Id” column in the data table. If it does not correspond, you need to update the property name in the entity class or regenerate the EF framework entity model.
  3. Check the EF entity model: If there is no property named “Id” in the EF framework entity class, or it corresponds to the “Id” column in the data table, then you need to check whether there is an element with the same name in the EF entity model. You can open the .edmx file and look for elements named “Id” in the “Model Browser”. If they exist, you need to delete them and regenerate the EF framework entity model.
  4. Check the EF entity model generation code: If the above steps do not resolve the issue, you need to check the EF entity model generation code. You can open the .edmx file, right-click on a blank area, and select “View Code” to open the code file. Search for “Id” in the code file to see if there are any duplicate definitions. If there are, you need to delete the duplicate definitions and regenerate the EF framework entity model.
| username: hey-hoho | Original post link

I think the query result has little to do with the version. According to SQL logic, what affects the query result is the order of fields in the columns table. I don’t quite understand why you need to query with “where t.id = 1”.

| username: zhanggame1 | Original post link

I don’t understand what this sentence is doing at all. What do you think it returns? Theoretically, it shouldn’t return anything.

| username: Cloud王 | Original post link

The EF framework does not execute this SQL; it executes a very complex SQL. Here, I just identified the SQL issue and extremely simplified it. I will post the original SQL later.

The problem with this minimal SQL is not caused by the id field name. Changing the SQL to

select * from
(select 6 c1 from INFORMATION_SCHEMA.COLUMNS where table_schema = 'test') t
where t.c1 = 1;

will also result in the same issue.

| username: Cloud王 | Original post link

Different versions produce different results for this SQL. The result is correct in version 4.0.15, but incorrect in version 6.5.3.
This is a minimal SQL problem; I will post the original SQL from the EF framework later.

| username: Cloud王 | Original post link

The original SQL for the EF framework is very long and complex. I’ll paste the original SQL below.

| username: Cloud王 | Original post link

The original SQL with issues in the EF framework:

SELECT `UnionAll1`.`C5` AS `C1`,
         `Extent1`.`Catalog`,
         `Extent1`.`Schema`,
         `Extent1`.`Name`,
         `UnionAll1`.`Name` AS `C2`,
         `UnionAll1`.`C1` AS `C3`,
         `UnionAll1`.`IsNullable` AS `C4`,
         `UnionAll1`.`TypeName` AS `C5`,
         `UnionAll1`.`C2` AS `C6`,
         `UnionAll1`.`C3` AS `C7`,
         `UnionAll1`.`DateTimePrecision` AS `C8`,
         `UnionAll1`.`C4` AS `C9`,
         `UnionAll1`.`IsIdentity` AS `C10`,
         `UnionAll1`.`IsStoreGenerated` AS `C11`,
    CASE
    WHEN (`Project5`.`C2` IS NOT NULL) THEN
    (`Project5`.`C2`)
    ELSE (0)
    END AS `C12`
FROM 
    (SELECT /* Tables */ CONCAT(TABLE_SCHEMA,
         '.', TABLE_NAME) AS `Id`, TABLE_CATALOG AS `Catalog`, TABLE_SCHEMA AS `Schema`, TABLE_NAME AS `Name`
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_TYPE = 'BASE TABLE'
            AND TABLE_SCHEMA=schema() ) AS `Extent1`
INNER JOIN (
    (SELECT `Extent2`.`Id`,
         `Extent2`.`Name`,
         `Extent2`.`Ordinal` AS `C1`,
         `Extent2`.`IsNullable`,
         `Extent2`.`TypeName`,
         `Extent2`.`MaxLength` AS `C2`,
         `Extent2`.`Precision` AS `C3`,
         `Extent2`.`DateTimePrecision`,
         `Extent2`.`Scale` AS `C4`,
         `Extent2`.`IsIdentity`,
         `Extent2`.`IsStoreGenerated`,
         0 AS `C5`,
         `Extent2`.`ParentId`
    FROM 
        (SELECT /* Table columns */ CONCAT(TABLE_SCHEMA,
         '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`, CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`, COLUMN_NAME AS `Name`, ORDINAL_POSITION AS `Ordinal`,
            CASE IS_NULLABLE
            WHEN 'YES' THEN
            1
            ELSE 0
            END AS `IsNullable`, IF(LEFT(COLUMN_TYPE,10) = 'tinyint(1)', 'bool', IF (LEFT(COLUMN_TYPE,10) = 'binary(16)'
                OR LEFT(COLUMN_TYPE,8) = 'char(36)', 'guid', IF (INSTR(COLUMN_TYPE, 'unsigned') = 0, DATA_TYPE, CONCAT('u', DATA_TYPE)))) AS `TypeName`, IF (CHARACTER_MAXIMUM_LENGTH > 2147483647, 2147483647, CHARACTER_MAXIMUM_LENGTH) AS `MaxLength`,
            CASE
            WHEN NUMERIC_PRECISION > 0 THEN
            CAST(NUMERIC_PRECISION AS CHAR)
            WHEN DATETIME_PRECISION > 0 THEN
            CAST(DATETIME_PRECISION AS CHAR)
            ELSE 0
            END AS `Precision`,
         DATETIME_PRECISION AS `DateTimePrecision`,
         NUMERIC_SCALE AS `Scale`,
         NULL AS `CollationCatalog`,
         NULL AS `CollationSchema`,
         COLLATION_NAME AS `CollationName`,
         NULL AS `CharacterSetCatalog`,
         NULL AS `CharacterSetSchema`,
         CHARACTER_SET_NAME AS `CharacterSetName`,
         0 AS `IsMultiSet`,
            CASE
            WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
            1
            WHEN EXTRA LIKE '%auto%' THEN
            1
            ELSE 0
            END AS `IsIdentity`,
            CASE
            WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
            1
            WHEN EXTRA LIKE '%auto%' THEN
            1
            ELSE 0
            END AS `IsStoreGenerated`, COLUMN_DEFAULT AS `Default`
        FROM INFORMATION_SCHEMA.COLUMNS
        WHERE TABLE_SCHEMA=schema() ) AS `Extent2`)
        UNION
        ALL 
            (SELECT `Extent3`.`Id`,
         `Extent3`.`Name`,
         `Extent3`.`Ordinal` AS `C1`,
         `Extent3`.`IsNullable`,
         `Extent3`.`TypeName`,
         `Extent3`.`MaxLength` AS `C2`,
         `Extent3`.`Precision` AS `C3`,
         `Extent3`.`DateTimePrecision`,
         `Extent3`.`Scale` AS `C4`,
         `Extent3`.`IsIdentity`,
         `Extent3`.`IsStoreGenerated`,
         6 AS `C5`,
         `Extent3`.`ParentId`
            FROM 
                (SELECT /* View columns */ CONCAT(TABLE_SCHEMA,
         '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`, CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`, COLUMN_NAME AS `Name`, ORDINAL_POSITION AS `Ordinal`,
                    CASE IS_NULLABLE
                    WHEN 'YES' THEN
                    1
                    ELSE 0
                    END AS `IsNullable`, IF(LEFT(COLUMN_TYPE,10) = 'tinyint(1)', 'bool', IF (LEFT(COLUMN_TYPE,10) = 'binary(16)'
                        OR LEFT(COLUMN_TYPE,8) = 'char(36)', 'guid', IF (INSTR(COLUMN_TYPE, 'unsigned') = 0, DATA_TYPE, CONCAT('u', DATA_TYPE)))) AS `TypeName`, IF (CHARACTER_MAXIMUM_LENGTH > 2147483647, 2147483647, CHARACTER_MAXIMUM_LENGTH) AS `MaxLength`,
                    CASE
                    WHEN NUMERIC_PRECISION > 0 THEN
                    CAST(NUMERIC_PRECISION AS UNSIGNED INTEGER)
                    WHEN DATETIME_PRECISION > 0 THEN
                    CAST(DATETIME_PRECISION AS UNSIGNED INTEGER)
                    ELSE 0
                    END AS `Precision`,
         0 AS `DateTimePrecision`,
         NUMERIC_SCALE AS `Scale`,
         NULL AS `CollationCatalog`,
         NULL AS `CollationSchema`,
         COLLATION_NAME AS `CollationName`,
         NULL AS `CharacterSetCatalog`,
         NULL AS `CharacterSetSchema`,
         CHARACTER_SET_NAME AS `CharacterSetName`,
         0 AS `IsMultiSet`,
                    CASE
                    WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
                    1
                    WHEN EXTRA LIKE '%auto%' THEN
                    1
                    ELSE 0
                    END AS `IsIdentity`,
                    CASE
                    WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
                    1
                    WHEN EXTRA LIKE '%auto%' THEN
                    1
                    ELSE 0
                    END AS `IsStoreGenerated`, COLUMN_DEFAULT AS `Default`
                FROM INFORMATION_SCHEMA.COLUMNS
                WHERE TABLE_SCHEMA=schema() ) AS `Extent3`)) AS `UnionAll1`
                ON (0 = `UnionAll1`.`C5`)
                AND (`Extent1`.`Id` = `UnionAll1`.`ParentId`) LEFT OUTER
    JOIN 
    (SELECT `UnionAll2`.`Id` AS `C1`,
         1 AS `C2`
    FROM 
        (SELECT /* Constraints */ CONCAT(CONSTRAINT_SCHEMA,
         '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `Id`, CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`, CONSTRAINT_NAME AS `Name`, CONSTRAINT_TYPE AS `ConstraintType`, 0 AS `IsDeferrable`, 0 AS `IsInitiallyDeferred`
        FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
        WHERE CONSTRAINT_TYPE != 'CHECK'
                AND TABLE_SCHEMA=schema() ) AS `Extent4`
        INNER JOIN (
            (SELECT 7 AS `C1`,
         `Extent5`.`ConstraintId`,
         `Extent6`.`Id`
            FROM 
                (SELECT /* Constraint columns */ CONCAT(CONSTRAINT_SCHEMA,
         '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `ConstraintId`, CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `ColumnId`
                FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
                WHERE TABLE_SCHEMA=schema() ) AS `Extent5`
                INNER JOIN 
                    (SELECT /* Table columns */ CONCAT(TABLE_SCHEMA,
         '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`, CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`, COLUMN_NAME AS `Name`, ORDINAL_POSITION AS `Ordinal`,
                        CASE IS_NULLABLE
                        WHEN 'YES' THEN
                        1
                        ELSE 0
                        END AS `IsNullable`, IF(LEFT(COLUMN_TYPE,10) = 'tinyint(1)', 'bool', IF (LEFT(COLUMN_TYPE,10) = 'binary(16)'
                            OR LEFT(COLUMN_TYPE,8) = 'char(36)', 'guid', IF (INSTR(COLUMN_TYPE, 'unsigned') = 0, DATA_TYPE, CONCAT('u', DATA_TYPE)))) AS `TypeName`, IF (CHARACTER_MAXIMUM_LENGTH > 2147483647, 2147483647, CHARACTER_MAXIMUM_LENGTH) AS `MaxLength`,
                        CASE
                        WHEN NUMERIC_PRECISION > 0 THEN
                        CAST(NUMERIC_PRECISION AS CHAR)
                        WHEN DATETIME_PRECISION > 0 THEN
                        CAST(DATETIME_PRECISION AS CHAR)
                        ELSE 0
                        END AS `Precision`,
         DATETIME_PRECISION AS `DateTimePrecision`,
         NUMERIC_SCALE AS `Scale`,
         NULL AS `CollationCatalog`,
         NULL AS `CollationSchema`,
         COLLATION_NAME AS `CollationName`,
         NULL AS `CharacterSetCatalog`,
         NULL AS `CharacterSetSchema`,
         CHARACTER_SET_NAME AS `CharacterSetName`,
         0 AS `IsMultiSet`,
                        CASE
                        WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
                        1
                        WHEN EXTRA LIKE '%auto%' THEN
                        1
                        ELSE 0
                        END AS `IsIdentity`,
                        CASE
                        WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
                        1
                        WHEN EXTRA LIKE '%auto%' THEN
                        1
                        ELSE 0
                        END AS `IsStoreGenerated`, COLUMN_DEFAULT AS `Default`
                    FROM INFORMATION_SCHEMA.COLUMNS
                    WHERE TABLE_SCHEMA=schema() ) AS `Extent6`
                        ON `Extent6`.`Id` = `Extent5`.`ColumnId`)
                    UNION
                    ALL 
                        (SELECT 11 AS `C1`,
         `Extent7`.`ConstraintId`,
         `Extent8`.`Id`
                        FROM 
                            (SELECT /* View constraint columns */ NULL AS `ConstraintId`,
         NULL AS `ColumnId` ) AS `Extent7`
                            INNER JOIN 
                                (SELECT /* View columns */ CONCAT(TABLE_SCHEMA,
         '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`, CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`, COLUMN_NAME AS `Name`, ORDINAL_POSITION AS `Ordinal`,
                                    CASE IS_NULLABLE
                                    WHEN 'YES' THEN
                                    1
                                    ELSE 0
                                    END AS `IsNullable`, IF(LEFT(COLUMN_TYPE,10) = 'tinyint(1)', 'bool', IF (LEFT(COLUMN_TYPE,10) = 'binary(16)'
                                        OR LEFT(COLUMN_TYPE,8) = 'char(36)', 'guid', IF (INSTR(COLUMN_TYPE, 'unsigned') = 0, DATA_TYPE, CONCAT('u', DATA_TYPE)))) AS `TypeName`, IF (CHARACTER_MAXIMUM_LENGTH > 2147483647, 2147483647, CHARACTER_MAXIMUM_LENGTH) AS `MaxLength`,
                                    CASE
                                    WHEN NUMERIC_PRECISION > 0 THEN
                                    CAST(NUMERIC_PRECISION AS UNSIGNED INTEGER)
                                    WHEN DATETIME_PRECISION > 0 THEN
                                    CAST(DATETIME_PRECISION AS UNSIGNED INTEGER)
                                    ELSE 0
                                    END AS `Precision`,
         0 AS `DateTimePrecision`,
         NUMERIC_SCALE AS `Scale`,
         NULL AS `CollationCatalog`,
         NULL AS `CollationSchema`,
         COLLATION_NAME AS `CollationName`,
         NULL AS `CharacterSetCatalog`,
         NULL AS `CharacterSetSchema`,
         CHARACTER_SET_NAME AS `CharacterSetName`,
         0 AS `IsMultiSet`,
                                    CASE
                                    WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
                                    1
                                    WHEN EXTRA LIKE '%auto%' THEN
                                    1
                                    ELSE 0
                                    END AS `IsIdentity`,
                                    CASE
                                    WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
                                    1
                                    WHEN EXTRA LIKE '%auto%' THEN
                                    1
                                    ELSE 0
                                    END AS `IsStoreGenerated`, COLUMN_DEFAULT AS `Default`
                                FROM INFORMATION_SCHEMA.COLUMNS
                                WHERE TABLE_SCHEMA=schema() ) AS `Extent8`
                                    ON `Extent8`.`Id` = `Extent7`.`ColumnId`)) AS `UnionAll2`
                                    ON (7 = `UnionAll2`.`C1`)
                                        AND (`Extent4`.`Id` = `UnionAll2`.`ConstraintId`)
                                WHERE `Extent4`.`ConstraintType` = 'PRIMARY KEY') AS `Project5`
                                ON `UnionAll1`.`Id` = `Project5`.`C1`
                        WHERE `Extent1`.`Name` LIKE '%'
| username: Cloud王 | Original post link

Assuming there is a table with two fields, id and name, in the test database.
Use test, then execute the original SQL:
In version 4.0.15, the result is normally two fields, id and name.
In version 6.5.3, however, four fields are returned, 2 id and 2 name.
(Randomly find a database with tables, use this database and execute the above original SQL, you will find that the data returned by 6.5.3 is always twice as much as that returned by 4.0.15)

Here is the problematic SQL extracted from the original SQL upstairs, and modified as follows:

select * from  (
    (SELECT `Extent2`.`Id`,
         `Extent2`.`Name`,
         `Extent2`.`Ordinal` AS `C1`,
         `Extent2`.`IsNullable`,
         `Extent2`.`TypeName`,
         `Extent2`.`MaxLength` AS `C2`,
         `Extent2`.`Precision` AS `C3`,
         `Extent2`.`DateTimePrecision`,
         `Extent2`.`Scale` AS `C4`,
         `Extent2`.`IsIdentity`,
         `Extent2`.`IsStoreGenerated`,
         0 AS `C5`,
         `Extent2`.`ParentId`
    FROM 
        (SELECT /* Table columns */ CONCAT(TABLE_SCHEMA,
         '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`, CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`, COLUMN_NAME AS `Name`, ORDINAL_POSITION AS `Ordinal`,
            CASE IS_NULLABLE
            WHEN 'YES' THEN
            1
            ELSE 0
            END AS `IsNullable`, IF(LEFT(COLUMN_TYPE,10) = 'tinyint(1)', 'bool', IF (LEFT(COLUMN_TYPE,10) = 'binary(16)'
                OR LEFT(COLUMN_TYPE,8) = 'char(36)', 'guid', IF (INSTR(COLUMN_TYPE, 'unsigned') = 0, DATA_TYPE, CONCAT('u', DATA_TYPE)))) AS `TypeName`, IF (CHARACTER_MAXIMUM_LENGTH > 2147483647, 2147483647, CHARACTER_MAXIMUM_LENGTH) AS `MaxLength`,
            CASE
            WHEN NUMERIC_PRECISION > 0 THEN
            CAST(NUMERIC_PRECISION AS CHAR)
            WHEN DATETIME_PRECISION > 0 THEN
            CAST(DATETIME_PRECISION AS CHAR)
            ELSE 0
            END AS `Precision`,
         DATETIME_PRECISION AS `DateTimePrecision`,
         NUMERIC_SCALE AS `Scale`,
         NULL AS `CollationCatalog`,
         NULL AS `CollationSchema`,
         COLLATION_NAME AS `CollationName`,
         NULL AS `CharacterSetCatalog`,
         NULL AS `CharacterSetSchema`,
         CHARACTER_SET_NAME AS `CharacterSetName`,
         0 AS `IsMultiSet`,
            CASE
            WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
            1
            WHEN EXTRA LIKE '%auto%' THEN
            1
            ELSE 0
            END AS `IsIdentity`,
            CASE
            WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
            1
            WHEN EXTRA LIKE '%auto%' THEN
            1
            ELSE 0
            END AS `IsStoreGenerated`, COLUMN_DEFAULT AS `Default`
        FROM INFORMATION_SCHEMA.COLUMNS
        WHERE TABLE_SCHEMA=schema() ) AS `Extent2`)
        UNION
        ALL 
            (SELECT `Extent3`.`Id`,
         `Extent3`.`Name`,
         `Extent3`.`Ordinal` AS `C1`,
         `Extent3`.`IsNullable`,
         `Extent3`.`TypeName`,
         `Extent3`.`MaxLength` AS `C2`,
         `Extent3`.`Precision` AS `C3`,
         `Extent3`.`DateTimePrecision`,
         `Extent3`.`Scale` AS `C4`,
         `Extent3`.`IsIdentity`,
         `Extent3`.`IsStoreGenerated`,
         6 AS `C5`,
         `Extent3`.`ParentId`
            FROM 
                (SELECT /* View columns */ CONCAT(TABLE_SCHEMA,
         '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`, CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`, COLUMN_NAME AS `Name`, ORDINAL_POSITION AS `Ordinal`,
                    CASE IS_NULLABLE
                    WHEN 'YES' THEN
                    1
                    ELSE 0
                    END AS `IsNullable`, IF(LEFT(COLUMN_TYPE,10) = 'tinyint(1)', 'bool', IF (LEFT(COLUMN_TYPE,10) = 'binary(16)'
                        OR LEFT(COLUMN_TYPE,8) = 'char(36)', 'guid', IF (INSTR(COLUMN_TYPE, 'unsigned') = 0, DATA_TYPE, CONCAT('u', DATA_TYPE)))) AS `TypeName`, IF (CHARACTER_MAXIMUM_LENGTH > 2147483647, 2147483647, CHARACTER_MAXIMUM_LENGTH) AS `MaxLength`,
                    CASE
                    WHEN NUMERIC_PRECISION > 0 THEN
                    CAST(NUMERIC_PRECISION AS UNSIGNED INTEGER)
                    WHEN DATETIME_PRECISION > 0 THEN
                    CAST(DATETIME_PRECISION AS UNSIGNED INTEGER)
                    ELSE 0
                    END AS `Precision`,
         0 AS `DateTimePrecision`,
         NUMERIC_SCALE AS `Scale`,
         NULL AS `CollationCatalog`,
         NULL AS `CollationSchema`,
         COLLATION_NAME AS `CollationName`,
         NULL AS `CharacterSetCatalog`,
         NULL AS `CharacterSetSchema`,
         CHARACTER_SET_NAME AS `CharacterSetName`,
         0 AS `IsMultiSet`,
                    CASE
                    WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
                    1
                    WHEN EXTRA LIKE '%auto%' THEN
                    1
                    ELSE 0
                    END AS `IsIdentity`,
                    CASE
                    WHEN COLUMN_DEFAULT LIKE 'CURRENT_TIMESTAMP' THEN
                    1
                    WHEN EXTRA LIKE '%auto%' THEN
                    1
                    ELSE 0
                    END AS `IsStoreGenerated`, COLUMN_DEFAULT AS `Default`
                FROM INFORMATION_SCHEMA.COLUMNS
                WHERE TABLE_SCHEMA=schema() ) AS `Extent3`)) AS `UnionAll1`
                where (0 = `UnionAll1`.`C5`)

Its abstract logic is actually like this:

select * from (
select 1 C5 from INFORMATION_SCHEMA.`COLUMNS` where table_schema='test'
union all
select 6 C5 from INFORMATION_SCHEMA.`COLUMNS` where table_schema='test'
) t where t.C5 =1 ;

Since version 6.5.3 cannot filter out the values where C5=6, the result of 6.5.3 is twice as much data as that of 4.0.15.
Therefore, after executing the original SQL, duplicate fields will appear in version 6.5.3, causing the EF framework to report duplicate field errors.