title: Entity Framework nvarchar Case Sensitivity on Foreign key
body: <p>I have fairly simple table structure as below and issue sounds strange to me. Though I have chosen to work around it but would like to take experts opinion.</p>
  
  <p>I have two Tables </p>
  
  <pre><code>Users
  UserName nvarchar(250) Primary Key
  FirstName nvarchar(50)
  LastName  nvarchar(50)
  
  Registrations
  Id BigInt PrimaryKey
  User nvarchar(250) - Foreign to Users Table
  Date - DateTime
  
  Data I have is as follows.
  Users
  UserName FirstName LastName
  a        Small     A 
  b        Small     B
  
  Registrations
  Id       User      Date
  1        A         1/1/12
  2        B         1/1/12
  </code></pre>
  
  <p>Please note Case of User here is Caps it is valid in SQL, it accepts.</p>
  
  <p>Now the Fun Part. I generated the EDMX, .Net 4.0  and Now I execute this code.</p>
  
  <pre><code> using (EFTestEntities context = new EFTestEntities())
              {
                  var item = context.Registrations.Where(id =&gt; id.Id == 1).FirstOrDefault();
                  Response.Write(item.User1.LastName);
              }
  </code></pre>
  
  <p>It Just Breaks with Null Pointer Exception User1 Throws Null, When I change the Value of UserName Column in Registrations table to <strong>a</strong> instead of <strong>A</strong> it works. </p>
  
  <p>This <a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/af3359a9-99bb-4e02-94dd-5b9a6a9cf0db" rel="nofollow noreferrer">Link</a> talks about somewhat Similar </p>
  
  <p>This <a href="https://stackoverflow.com/questions/7421919/entity-framework-code-first-case-sensitivity-on-string-pk-fk-relationships">Link</a> another similar issue</p>
  
  <p>Please share your answers why is this behaviour, Collation of my DB is case-insentivity. Have you faced similar ?</p>