title: Entity Framework varchar foreign key case insensitive
body: <p>A couple of years ago the following question was asked: <a href="https://stackoverflow.com/questions/9751647/entity-framework-nvarchar-case-sensitivity-on-foreign-key">Entity Framework nvarchar Case Sensitivity on Foreign key</a>.</p>
  
  <p>In short the answer was: EF uses the CLR to compare the keys of lazily loaded associations and always does that in a case sensitive manner, even though the database is set to a case insensitive collation.</p>
  
  <p>Unfortunately, the project I'm currently involved with heavily uses VARCHAR primary key columns. The database collation is case insensitive.</p>
  
  <p>Fixing the database design is really not an option, besides perhaps setting a CS collation on the primary key columns (but that would potentially break client applications).</p>
  
  <p>So my question is two-fold:</p>
  
  <ol>
  <li>Does Entity Framework nowadays provide a directive or a setting of
  some kind, to instruct it to do case insensitive comparisons?</li>
  <li>If not, can a trigger be used to automatically change the foreign key
  to match the casing of the primary key? Or can you think of any
  other workarounds?</li>
  </ol>
  
  <p>BTW: SQL Server 2008 R2 and Entity Framework version 6.</p>