Documentation for EF Core, 1 to many model binding while saving to DB
Not sure if I missed it, although I saw the 1 to many model mapping in the documentation on the complex data model section, I did not see how to retrieve it from the UI or how the controller should get the data. I saw some reference to use a ICollection of an object to store the data. In my case, trying to retrieve a list of items from multiple select does not work as I am unsure how to pass the data to the controller from the view. Help us make content visible
- Tell us what search terms you used and how you searched docs.
- Tell us what docs you found that didn't address your concern.
Describe the new topic
- Explain why this topic is needed.
- Suggest a location in the Table of Contents.
- Write an abstract. In one short paragraph, describe what this topic will cover.
- Create an outline for the new topic. We'll help review the outline and approve it before anyone writes a topic.
Hello @Kool-Koder ... Thanks for commenting. It's best to open issues from the Content feedback button at the bottom of the topic to tag the issue with the topic metadata. Anyway .... which topic are you looking at for this issue? You can paste the link into a comment here.
Hi @guardrex the link I'm referring to in general is https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro?view=aspnetcore-2.0 The tutorial if I didn't miss it doesn't seem to cover returning a list from the view to the controller.
From what I understand mutliple select in HTML return and array or List something along this lines, but what I cannot figure out is how the controller and model should be written in such a way that an object can hold a list of items and pass it to the controller.
I did try multiple select and setting asp-for="" for select multiple, but that's as far as I can go.
See :point_right: Select Tag Helper: Multiple select
The tutorial wasn't written to cover this scenario by-design AFAIK. I'll close as answered, but @Rick-Anderson or @tdykstra will re-open if they would like to include a multiple select in the tutorial and work it from here.
@Kool-Koder Did you look at the update related data tutorial? https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/update-related-data?view=aspnetcore-2.0
It returns a list of checkboxes, not a multi-select but might be helpful.