title: The declared type of navigation property Project.Models.Customer.SubCustomers is not compatible with the result of the specified navigation
body: <p>I have had a look at answers to similar errors, but I can't seem to find an answer to my particular error.</p>
  
  <p>I am running a migration and the error happens when the seed method is run (migration has worked fine).</p>
  
  <blockquote>
    <p>The declared type of navigation property Project.Models.Customer.SubCustomers is not compatible with the result of the specified navigation.</p>
  </blockquote>
  
  <p>This is for a circular reference, i.e. a Customer can have 0..* SubCustomers and 0..1 ParentCustomers.</p>
  
  <p>Customer model:</p>
  
  <pre><code>public class Customer : Entity
  {
      public int CustomerId { get; set;}
      public string Name { get; set; }
  
      // Relationships
  
      public int? ParentCustomerId { get; set; }
      public virtual ICollection&lt;Customer&gt; SubCustomers { get; set; } // a Customer has many Customers as SubCustomers, a Customer has zero or one ParentCustomer
  
      // Other relationships
  }
  </code></pre>
  
  <p>From context fluent api:</p>
  
  <pre><code>modelBuilder.Entity&lt;Customer&gt;()
              .HasKey(customer =&gt; customer.CustomerId);
  modelBuilder.Entity&lt;Customer&gt;()
              .Property(customer =&gt; customer.Name)
              .IsRequired()
              .HasColumnType("nvarchar")
              .HasMaxLength(500);
  modelBuilder.Entity&lt;Customer&gt;() // a Customer has many Customers as SubCustomers, a Customer has zero or one ParentCustomer
              .HasOptional(customer =&gt; customer.SubCustomers)
              .WithMany()
              .HasForeignKey(customer =&gt; customer.ParentCustomerId);
  </code></pre>
  
  <p>From seed method: (the customers are created in the database, sub-customers does not work)</p>
  
  <pre><code>// Default Customers - create and save
  var customers = new[]{
      new Customer { Name = "Custa" },
      new Customer { Name = "Custb" },
      new Customer { Name = "Custc" }
  };
  context.Customers.AddOrUpdate(r =&gt; r.Name, customers[0], customers[1], customers[2]);
  context.SaveChanges();
  
  // Add SubCustomers b &amp; c to Customer a (ids calculated beforehand, e.g. aId, as linq does not support array index)
  var aId = customers[0].CustomerId;
  var a = context.Customers.Include(c =&gt; c.SubCustomers).SingleOrDefault(c =&gt; c.CustomerId == aId);
  if (a.SubCustomers == null)
      a.SubCustomers = new List&lt;Customer&gt;();
  var bId = customers[1].CustomerId;
  var b = a.SubCustomers.SingleOrDefault(c =&gt; c.CustomerId == bId);
  if (b == null)
      a.SubCustomers.Add(context.Customers.Single(c =&gt; c.CustomerId == bId));
  var cId = customers[2].CustomerId;
  var c = a.SubCustomers.SingleOrDefault(c =&gt; c.CustomerId == cId);
  if (c == null)
      a.SubCustomers.Add(context.Customers.Single(c =&gt; c.CustomerId == cId));
  context.SaveChanges();
  </code></pre>
  
  <p>If anyone can spot what is causing the error I would be very grateful. Many thanks!</p>