title: Entity Framework - Table Per Type Not Working
body: <p>I'm using Entity Framework 4.0 and I have 4 tables: <code>History</code>, <code>TedReceived</code>, <code>TedReplied</code> and <code>ConfirmedCredit</code>.</p>
  
  <p>In the entity classes History is abstract and TedReceived, TedReplied and ConfirmedCredit inherit from History.</p>
  
  <p>In DB the last three tables has a primary+foreign key IdHistory. (1-1 Relationship with History).</p>
  
  <p>Now I mapped the classes like this:</p>
  
  <p>In context:</p>
  
  <pre><code>modelBuilder.Configurations.Add(new HistoryMap());
  modelBuilder.Configurations.Add(new TedReceivedMap());
  modelBuilder.Configurations.Add(new TedRepliedMap());
  modelBuilder.Configurations.Add(new ConfirmedCreditMap());
  </code></pre>
  
  <p>But this exception is throw:</p>
  
  <blockquote>
    <blockquote>
      <p>(322,10) : error 3032: Problem in mapping fragments starting at lines 310, 322:EntityTypes TedReceivedEntity, TedRepliedEntity, ConfirmedCreditEntity are being mapped to the same rows in table HistoryEntity. Mapping conditions can be used to distinguish the rows that these types are mapped to.</p>
    </blockquote>
  </blockquote>
  
  <p>Anyone can help me?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>In <code>HistoryMap</code> class:</p>
  
  <pre><code>public HistoryMap()
  {
      HasKey(t =&gt; t.IdHistory);
  
      Property(t =&gt; t.IdHistory).HasColumnName("IdHistory");
      Property(t =&gt; t.IdSinister).HasColumnName("IdSinister");
      Property(t =&gt; t.IdUser).HasColumnName("IdUser");
      Property(t =&gt; t.IdSinisterStatus).HasColumnName("IdSinisterStatus");
      Property(t =&gt; t.UpdateDate).HasColumnName("UpdateDate");
  
      // Relationships
      this.HasRequired(t =&gt; t.Sinister)
          .WithMany(t =&gt; t.History)
          .HasForeignKey(d =&gt; d.IdSinister);
      this.HasRequired(t =&gt; t.SinisterStatus)
          .WithMany(t =&gt; t.History)
          .HasForeignKey(d =&gt; d.IdSinisterStatus);
      this.HasRequired(t =&gt; t.User)
          .WithMany(t =&gt; t.History)
          .HasForeignKey(d =&gt; d.IdUser);
  
      ToTable("History", "dbo");
  }
  </code></pre>
  
  <p>In <code>TedReceivedMap</code> class:</p>
  
  <pre><code>public TedReceived()
  {
      HasKey(t =&gt; t.IdHistory);
  
      Property(t =&gt; t.IdHistory).HasColumnName("IdHistory");
      Property(t =&gt; t.Observation).HasColumnName("Observation");
  
      ToTable("TedReceived", "dbo");
  }
  </code></pre>
  
  <p>The exception occurs when the context class is instantiated:</p>
  
  <pre><code>var db = new Context();
  </code></pre>