work on asp.net mvc5 ef-6.Face problem with many to many relational table data insertion.My classes models are
public class Product
{
public long ProductID { get; set; }
public string ProductName { get; set; }
//navigation property to Supplier
public virtual ICollection<ProductSupplier> ProductSupplier { get; set; }
}
public class Supplier
{
public long SupplierID { get; set; }
public string SupplierName { get; set; }
// navigation property to Product
public virtual ICollection<ProductSupplier> ProductSupplier { get; set; }
}
public class ProductSupplier
{
public long ProductID { get; set; }
public long SupplierID { get; set; }
public virtual Product Product { get; set; }
public virtual Supplier Supplier { get; set; }
public bool IsActive { get; set; }
}
How to insert records on above classes.Will first i need to insert on Product then Supplier then ProductSupplier.