Andre Silveira

Andre Silveira

  • 1.2k
  • 148
  • 13.4k

A many to many relationship on the same table

Jun 5 2023 9:03 PM
public class Product
{
 public int Id { get; set; }
 public string Name{ get; set; }
// lotsa other stuff
 public ICollection<Product> RelatedProduct{ get; set; }
}

Hi, 

Let's say I have a table "Product"

That table has a collection of 'Related Products'

Ho do I configure it on the DbContext fulent api so it creates the link table?

One product can be in many "relatedproducts" and each product can have many "relatedproducts"


Answers (4)