Reputation: 109
I'm using MVC 3 with Razor and Entity Framework for an assignment.
So far, I have been using scaffolds to create a basic CRUD page for all my models.
Two of the models I have are Musicians and Sessions, this is a many-to-many relationship (there is a pivot table for them in the database, but not in the models).
Basically, I need some way of assigning musicians to sessions, but I've noticed that all my properties get populated by the Razor tag, @Html.EditorFor(model => model.SomeProperty)
, but how can I get this to work with a collection?
Upvotes: 1
Views: 1195
Reputation: 309
I would suggest you look here:
stuck with asp.net mvc 3.0 Scaffolding in case of many to many relationship
By default, ASP.NET MVC 3 doesn't scaffold many-to-many relationships. As mentioned in that link, your best option is to scaffold your Session or Musician and then hand-code the selection of the other model in each view.
Upvotes: 1