Good evening! I use Asp.net MVC with EF. I have 2 models
public class Product
{
public int ID { get; set; }
public string Name { get; set; }
public ICollection<Category> categories { get; set; }
}
public class Category
{
public int ID { get; set; }
public string Name { get; set; }
public ICollection<Product> products { get; set; }
}
many-to many add normaly work, if I add new product, but if i try update product entity,new relationship doesnt add. I add new products like this
Product product= new Product{...};
product.categories.Add(db.Categories.First())//example
How I can add/delete relationships in product entity update?