stuck with asp.net mvc 3.0 Scaffolding in case of many to many relationship

守給你的承諾、 提交于 2019-11-30 16:11:45

Scott Hanselman's answer is correct - many-to-many relationships are outside the scope of what scaffolding will handle natively (the reason for this is partly that there are simply too many different common kinds of many-to-many-editing UIs that it's extremely unlikely we can adequately guess what sort of UI you want).

Two options:

  1. Use scaffolding as a starting point and, from what you've already got, add a multiselect list onto your "Edit Project" screen so users can add/remove tags. This is a manual development step and will require more familiarity with ASP.NET MVC development.
  2. Alternatively, you can create an explicit "link entity", e.g. called TagAssignment, that has a one-to-many relationship with both Project and Tag (so a Project has many TagAssignments, and a Tag has many TagAssignments). Then scaffolding will be able to generate for you a UI for creating arbitrary numbers of TagAssignments between projects and tags.

You may have reached the limits of the "jump start" that Scaffolding provides and may need to write your views on your own. I'll ask Steve Sanderson.

why you do not make a view that do that or you can create a stored procedure in your data base that implement that then you can use in you code in a simple way because the ef has a problem of many to many relationship think out of the box i am sure you are going to get an answer :) mark as answer if it helps

notice : for me i use a custom data access layer not mvc model because i have a lot of custom requirements for my projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!