title: Trying to set a non-null string to type 'System.Int32'
body: <p>Entity Framework is throwing this exception:</p>
  
  <blockquote>
    <p>The 'PasswordIterations' property on 'BranchIdentity' could not be set to a 'System.String' value. You must set this property to a non-null value of type 'System.Int32'.</p>
  </blockquote>
  
  <p>It's throwing on this line:</p>
  
  <pre><code>// Validate uniqueness or email and username
  var user = sqlStorage.BranchIdentities.FirstOrDefault(i =&gt; i.Username.ToLower() == viewModel.Username.ToLower());
  </code></pre>
  
  <p>The exception only throws when there is an entity that matches the query. If there are no matches, the exception isn't thrown.</p>
  
  <p>My BranchIdentity model:</p>
  
  <pre><code>namespace Branch.Models.Sql
  {
      public class BranchIdentity
      {
          [Key]
          public int Id { get; set; }
  
          [Required]
          public string Username { get; set; }
  
          [Required]
          public string PasswordHash { get; set; }
  
          [Required]
          public string PasswordSalt { get; set; }
  
          [Required]
          public int PasswordIterations { get; set; }
  
          [Required]
          public string Email { get; set; }
  
          [Required]
          public string FullName { get; set; }
  
          public virtual ICollection&lt;BranchIdentitySession&gt; BranchIdentitySessions { get; set; } 
  
          public virtual BranchRole BranchRole { get; set; }
  
          public virtual GamerIdentity GamerIdentity { get; set; }
      }
  }
  </code></pre>
  
  <p>And my schema (taken from the sql database) - auto-generated using code-first migrations:</p>
  
  <pre><code>CREATE TABLE [dbo].[BranchIdentities] (
      [Id]                 INT            IDENTITY (1, 1) NOT NULL,
      [Username]           NVARCHAR (MAX) NOT NULL,
      [PasswordHash]       NVARCHAR (MAX) NOT NULL,
      [PasswordSalt]       NVARCHAR (MAX) NOT NULL,
      [PasswordIterations] INT            NOT NULL,
      [Email]              NVARCHAR (MAX) NOT NULL,
      [BranchRole_Id]      INT            NULL,
      [GamerIdentity_Id]   INT            NULL,
      [FullName]           NVARCHAR (MAX) DEFAULT ('') NOT NULL,
      CONSTRAINT [PK_dbo.BranchIdentities] PRIMARY KEY CLUSTERED ([Id] ASC),
      CONSTRAINT [FK_dbo.BranchIdentities_dbo.BranchRoles_BranchRole_Id] FOREIGN KEY ([BranchRole_Id]) REFERENCES [dbo].[BranchRoles] ([Id]),
      CONSTRAINT [FK_dbo.BranchIdentities_dbo.GamerIdentities_GamerIdentity_Id] FOREIGN KEY ([GamerIdentity_Id]) REFERENCES [dbo].[GamerIdentities] ([Id])
  );
  </code></pre>
  
  <p>I have tried making <code>PasswordIterations</code> nullable, but to no avail.</p>