How to keep track of third property in Many-To-Many
I have 2 models one that is Reservation and one that is Menu, They have a many-to-many relation but I wanna keep track on the reservation how many times one menu is ordered for that resrevation.
This is my current many-to-many table :
This is my current OnModelCreating for that table
I am kinda stuck on how to approach this.
2 Replies
why do you want to store this separately?
cant you query it with something like
_context.Menus.Count(m => m.Reservations.Any(r => r.Id == reservationId))
?I could try that good point
That worked!