Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF Core 8 - Oracle - Ignore Case Sensitivity in Primary Key Column Leads to Incorrect Data Loading #32751

Closed
Avienda opened this issue Jan 9, 2024 · 1 comment

Comments

@Avienda
Copy link

Avienda commented Jan 9, 2024

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

@ajcvickers
Copy link
Contributor

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.

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants