title: Entity Framework 6 - The type has already been configured as an entity type. It cannot be reconfigured as a complex type
body: <p>I have an entity which I've made a minor change to.  I've made the foreign key non nullable and required.
  When I've come to create the Entity Framework migration I'm receiving an error:</p>
  
  <blockquote>
    <p>The type 'Payment' has already been configured as an entity type. It
    cannot be reconfigured as a complex type.</p>
  </blockquote>
  
  <p>I can't see why this is the case.  I've not defined any class as a complex type.
  I'm using an Enum, but that has always been there and never been a problem before and supported under EF6.</p>
  
  <p>The project itself still compiles fine.</p>
  
  <p>Here is the Payment class which is causing the problem.</p>
  
  <pre><code>public partial class Payment
  {
      public int payment_ID { get; set; }
      public int order_ID { get; set; }
      public PaymentTypeEnum paymentType_ID { get; set; }
      public string cc_response_ReceiptNo { get; set; }
      public string cc_response_QSIResponseCode { get; set; }
      public string cc_response_QSIResponseDescription { get; set; }
      public string cc_response_TransactionNo { get; set; }
      public string cc_response_BatchNo { get; set; }
      public DateTime? cc_response_expected { get; set; }
      public bool? cc_response_checked { get; set; }
      public DateTime? paymentReceived { get; set; }
      public int? paymentAmountUnits { get; set; }
      public string paymentNotes { get; set; }
      public string cc_GatewayIdent { get; set; }
      public virtual Order Order { get; set; }
      public virtual PaymentType PaymentType { get; set; }
      public virtual ICollection&lt;CreditNote&gt; CreditNotes { get; set; }
  }
  </code></pre>
  
  <p>Mapping information</p>
  
  <pre><code> public class tbl_paymentMap : EntityTypeConfiguration&lt;Payment&gt;
  {
      public tbl_paymentMap()
      {
          // Primary Key
          this.HasKey(t =&gt; t.payment_ID);
  
          // Properties
          this.Property(t =&gt; t.cc_response_ReceiptNo)
              .HasMaxLength(12);
  
          this.Property(t =&gt; t.cc_response_QSIResponseCode)
              .HasMaxLength(2);
  
          this.Property(t =&gt; t.cc_response_QSIResponseDescription)
              .HasMaxLength(150);
  
          this.Property(t =&gt; t.cc_response_TransactionNo)
              .HasMaxLength(21);
  
          this.Property(t =&gt; t.cc_response_BatchNo)
              .HasMaxLength(21);
  
          this.Property(t =&gt; t.paymentNotes)
              .HasMaxLength(100);
  
          this.Property(t =&gt; t.cc_GatewayIdent)
              .HasMaxLength(50);
  
          // Table &amp; Column Mappings
          this.ToTable("tbl_payment");
          this.Property(t =&gt; t.payment_ID).HasColumnName("payment_ID");
          this.Property(t =&gt; t.order_ID).HasColumnName("order_ID");
          this.Property(t =&gt; t.paymentType_ID).HasColumnName("paymentType_ID");
          this.Property(t =&gt; t.cc_response_ReceiptNo).HasColumnName("cc_response_ReceiptNo");
          this.Property(t =&gt; t.cc_response_QSIResponseCode).HasColumnName("cc_response_QSIResponseCode");
          this.Property(t =&gt; t.cc_response_QSIResponseDescription).HasColumnName("cc_response_QSIResponseDescription");
          this.Property(t =&gt; t.cc_response_TransactionNo).HasColumnName("cc_response_TransactionNo");
          this.Property(t =&gt; t.cc_response_BatchNo).HasColumnName("cc_response_BatchNo");
          this.Property(t =&gt; t.cc_response_expected).HasColumnName("cc_response_expected");
          this.Property(t =&gt; t.cc_response_checked).HasColumnName("cc_response_checked");
          this.Property(t =&gt; t.paymentReceived).HasColumnName("paymentReceived");
          this.Property(t =&gt; t.paymentAmountUnits).HasColumnName("paymentAmountUnits");
          this.Property(t =&gt; t.paymentNotes).HasColumnName("paymentNotes");
          this.Property(t =&gt; t.cc_GatewayIdent).HasColumnName("cc_GatewayIdent");
  
          // Relationships
          this.HasRequired(t =&gt; t.Order)
              .WithMany(t =&gt; t.Payments)
              .HasForeignKey(d =&gt; d.order_ID);
          this.HasRequired(t =&gt; t.PaymentType)
              .WithMany(t =&gt; t.Payments)
              .HasForeignKey(d =&gt; d.paymentType_ID);
     }
  }
  </code></pre>