The following question was asked a few years ago: Entity Framework nvarchar Case-sensitive foreign key .
In short, the answer was: EF uses the CLR to compare keys for lazy-loaded associations and always makes it case-sensitive, even if the database is set up for case-insensitive sorting.
Unfortunately, the project I am currently involved in uses the VARCHAR primary key columns. Database mapping is case insensitive.
Committing a database design is not really an option, other than possibly setting up CS mapping in primary key columns (but this could potentially break client applications).
So my question is twofold:
- Does Entity Framework provide a directive or setting of some kind to enable it to make case insensitive comparisons?
- If not, can the trigger be used to automatically change the foreign key to match the primary key case? Or can you think of any other workarounds?
BTW: SQL Server 2008 R2 and Entity Framework version 6.
source share