title: Entity Framework Core 3.1.6 Item With Same Key Has Already Been Added
body: <p>I have a MVC website in .NET Core 3.1 using Entity Framework 3.1.6. My issue is that one of my entities now throws and error:</p>
  <blockquote>
  <p>System.ArgumentException: An item with the same key has already been added. Key: Assessor</p>
  </blockquote>
  <p>It was working fine up until recently and I'm not sure what changed.</p>
  <p><strong>Model</strong></p>
  <pre><code>public class FacilityQCResult
  {
      [Key]
      public int ID { get; set; }
      public Guid? QCID { get; set; }
      public string QCSeverity { get; set; }
      public string QCType { get; set; }
      public string QCShortName { get; set; }
      public string Resolution { get; set; }
      public string Base { get; set; }
      public string FacilityNumber { get; set; }
      public string FacilityName { get; set; }
      public DateTime? DataEntryComplete { get; set; }
      public string TeamAssignment { get; set; }
      public string Assessor { get; set; }
      public string TripWeek { get; set; }
      public string Details { get; set; }
      public Guid? FacilityID { get; set; }
  }
  </code></pre>
  <p><strong>Context</strong></p>
  <pre><code>public partial class SQLDBContext : DbContext
  {
      public SQLDBContext()
      {
      }
  
      public SQLDBContext(DbContextOptions&lt;SQLDBContext&gt; options)
          : base(options)
      {
      }
      
      
      public virtual DbSet&lt;FacilityQCResult&gt; FacilityQCResults { get; set; }
      
   protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;FacilityQCResult&gt;(entity =&gt;
          {
              entity.ToTable(&quot;FacilityQCResult&quot;);
              entity.HasKey(e =&gt; e.ID);
  
              entity.Property(e =&gt; e.DataEntryComplete)
                  .HasColumnName(&quot;Data_Entry_Complete&quot;)
                  .HasColumnType(&quot;datetime&quot;);
  
              entity.Property(e =&gt; e.TeamAssignment)
                  .HasColumnName(&quot;Team_Assignment&quot;)
                  .HasMaxLength(100)
                  .IsUnicode(false);
  
              entity.Property(e =&gt; e.TripWeek)
                  .HasColumnName(&quot;Trip_Week&quot;)
                  .HasMaxLength(10)
                  .IsUnicode(false);
          });
      }
  }
  </code></pre>
  <p><strong>Table Structure</strong></p>
  <p><a href="https://i.stack.imgur.com/lbgG8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lbgG8.png" alt="enter image description here" /></a></p>
  <p>It throws an error when it gets to the following line:</p>
  <pre><code>var result = await context.FacilityQCResults.FromSqlRaw(&quot; exec [dbo].[pr_ExecuteFacilityQCRules]&quot;).ToListAsync();
  </code></pre>
  <p>The stored procedure does some other stuff and spits out rows of data that models the table structure. Funny thing is I have another object that is set up similar that runs with no issues. This one seemed to work until recently, but I'm not sure exactly when this starting happening or why as I have not changed the object or table structure. Basically, EF Core thinks the Assessor column is a key despite me not specifying so. How is this happening and how do I tell it that it is not a key?</p>