title: C# Entity Framework SQL Error
body: <p>I have an EmailHistoryModel :</p>
  
  <pre><code>public class EmailHistory
  {
      public Guid Id { get; set; }
      public string CompanyId { get; set; }
      public Guid? UserId { get; set; }
      public DateTime CreatedDate { get; set; }
      public DateTime SentDate { get; set; }
      public DateTime UpdateDate { get; set; }
      public string OutCome { get; set; }
      public DateTime EmailDeliveredDate { get; set; }
      public DateTime EmailOpened { get; set; }
      public string EmailAddress { get; set; }
      public string HtmlEmail { get; set; }
      public string IntegrationDocumentId { get; set; }
      public Rules RulesId { get; set; }
      public int TransactionId { get; set; }
  }
  </code></pre>
  
  <p>I keep getting an error when trying to access my model. At the moment i am trying to run the following :</p>
  
  <pre><code>var emailHistoryTotal = !emailHistory.Any() ? 1 : emailHistory.Count();
  </code></pre>
  
  <p>This keeps giving me the error : "EntityFramework.dll but was not handled in user code</p>
  
  <p>Additional information: Conversion failed when converting from a character string to uniqueidentifier"</p>
  
  <p>I'm not sure what has changed as it was all working ok..... </p>
  
  <p>If i run the following in SQL, it returns ok!?: SELECT * FROM [dbo].[EmailHistory]</p>
  
  <p>In SQL the only columns set to Unique Identifier are the Id, RulesId_Id and the UserId.</p>
  
  <p>The emailHistory is comming from my repository (see below for the method)</p>
  
  <pre><code>public IQueryable&lt;EmailHistory&gt; GetEmailHistoryByUser(string userId)
      {           
          return _autoSendContext.EmailHistory.AsQueryable();
      }
  </code></pre>
  
  <p>the _autoSendContext is a global variable to interact with the db </p>
  
  <p>Any help or guidance would be great!</p>