title: Entity Framework 6 Code First case insensitive string association
body: <p>I'm migrating an LINQ to SQL project to EF 6.1.3 Code First. The problem I'm facing is:</p>
  
  <p>I have 2 tables, Incidents with debtorNo column (varchar(20) not null) and Debtors With a No column (varchar(20) not null) which is the primary key. The schema cannot change because these tables are populated by an external system on which I have no control. There is no foreign key between the tables in the db as the tables are populated asynchronously (again no control over that). The db collation is case insensitive.</p>
  
  <p>In LINQ to SQL I declared an association between the tables for navigation. In EF I declared the same association with the following code in the DbContext's OnModelCreating method:</p>
  
  <pre><code>modelBuilder.Entity&lt;Incident&gt;()
              .HasRequired(e =&gt; e.Debtor)
              .WithMany(e =&gt; e.Incidents)
              .HasForeignKey(e =&gt; e.DebtorNo);
  </code></pre>
  
  <p>While LINQ to SQL association was case insensitive the EF association is not. After googling the problem I found 2 solutions:</p>
  
  <ol>
  <li>Create and use views that convert the strings to upper or lower case.</li>
  <li>Manipulate the data</li>
  </ol>
  
  <p>These solutions are perfectly working (I'll probably use the second one) but were dated a couple of years ago and referred to EF 4.1 Code First.</p>
  
  <p>So my question is is there a way to declare a case insensitive string association in the latest version of EF Code First?</p>