I'm trying to build many, many relationships using an entity structure and a free API, but I'm stuck trying to allow duplicate entries. Here is what I have:
public class Pizza
{
public int PizzaId { get; set; }
public virtual ICollection<Topping> Toppings { get; set; }
}
public class Topping
{
public int ToppingId { get; set; }
}
- Any pizza must have several toppings.
- Any file can be applied to several pizzas.
So in OnModelCreating()I call:
modelBuilder.Entity<Pizza>()
.HasMany(p => p.Toppings)
.WithMany()
.Map(m => m.ToTable("ToppingsForPizza"));
This gives me a good many-to-many relationship, but the problem is that I want the pizza to have multiple instances of the same topping , for example. double pepperoni
The database ToppingsForPizzathat is generated cannot support this ... I assume there must be a unique primary key.
Is there any way to do this?
EDIT: , , .