Is there an alternative to using Include
to eager load entities?
The reason I can't use Include
is that it appears to be case sensitive.
Consider the following example:
I have two tables:
Notes the difference in case.
When I want to eager load Sager
's Stamkartotek
I use Include
, but the Include
doesn't load Stamkartotek
:
** Update 1 **
I noticed this strange behavior - if I use any fields from Stamkartotek
it joins correctly:
But if I go and only retrieve the value of Stam_nr
instead of the whole object - it gives me A
instead of a
:
Research so far:
- The EF team knows about this problem - but have decided not to fix it.
- This guy has the same problem only using code-first - no solution has been found
Update 2
SQL genereted with Include
:
FROM [dbo].[Sager] AS [Extent1]
INNER JOIN [dbo].[Stamkartotek] AS [Extent2] ON [Extent1].[Klient_Stam_nr] = [Extent2].[Stam_nr]
WHERE 'jek15' = [Extent1].[Sags_nr]
Update 3
Loading them in seperate queries, and letting changetracker fixup the reference. It doesn't seem to work either:
Include
, it's in the SQL generator when associations use text fields. Using text data for keys is an uncommon practice anyway (for the reasons you just encountered). Or, you could download the EF code (it's OSS) and fix it, if you have the time ... – Dacha