You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading to EF Core 8, we encountered a behavioral change regarding how EF Core handles case sensitivity in primary key columns. Specifically, in a scenario involving a varchar2 column used as a primary key, EF Core seems to ignore case differences. For instance,
when the database has columns NAME VARCHAR2(50 BYTE) AS PRIMARY KEY, and ID NUMBER, if one row has name = 'Test' , Id = 80, and the other row has Name = 'TEST' , Id = 345 , EF Core incorrectly loads these as duplicate entries with the same case (e.g., both as 'TEST') in the DbContext. This behavior is inconsistent with previous versions and leads to incorrect data representation in the application. In total the dbSet in code has the same number of rows as counted in the database directly, but some of them have been overwritten due to this bug.
When the primary key is set to use Id column, there is no issue, because a number can't be case sensitive, but when it is referring to a string column, this bug exists. This was not the case before upgrading to .Net Core 8.
We've tried to use db collation with
ALTER TABLE CLIENTS MODIFY (NAME VARCHAR2(50 BYTE) COLLATE BINARY);
and useCollation() in EntityFramework Entity Configuration, it didn't help.
Include provider and version information
EF Core version: 8.0
Database provider: Oracle.EntityFrameworkCore
Target framework: .NET 8.0
Operating system: Windows 11
IDE: Visual Studio 2022 17.8.3 or Rider 2023.3.2
The text was updated successfully, but these errors were encountered:
This behavior is defined by the Oracle provider, and so should be reported to Oracle. That being said, we made a similar change for SQL Server: #27526. That issue links some examples of switching the comparison back.
File a bug
After upgrading to EF Core 8, we encountered a behavioral change regarding how EF Core handles case sensitivity in primary key columns. Specifically, in a scenario involving a varchar2 column used as a primary key, EF Core seems to ignore case differences. For instance,
when the database has columns NAME VARCHAR2(50 BYTE) AS PRIMARY KEY, and ID NUMBER, if one row has name = 'Test' , Id = 80, and the other row has Name = 'TEST' , Id = 345 , EF Core incorrectly loads these as duplicate entries with the same case (e.g., both as 'TEST') in the DbContext. This behavior is inconsistent with previous versions and leads to incorrect data representation in the application. In total the dbSet in code has the same number of rows as counted in the database directly, but some of them have been overwritten due to this bug.
When the primary key is set to use Id column, there is no issue, because a number can't be case sensitive, but when it is referring to a string column, this bug exists. This was not the case before upgrading to .Net Core 8.
We've tried to use db collation with
ALTER TABLE CLIENTS MODIFY (NAME VARCHAR2(50 BYTE) COLLATE BINARY);
and useCollation() in EntityFramework Entity Configuration, it didn't help.
Include provider and version information
EF Core version: 8.0
Database provider: Oracle.EntityFrameworkCore
Target framework: .NET 8.0
Operating system: Windows 11
IDE: Visual Studio 2022 17.8.3 or Rider 2023.3.2
The text was updated successfully, but these errors were encountered: