Entity Framework and MVC Scaffolding with Composite Primary Keys

别等时光非礼了梦想. 提交于 2020-01-02 09:29:34

问题


I'm curious about how Entity Framework and MVC scaffolding handle primary keys. When I create a controller in an MVC3 project and choose the scaffolding template of 'Controller with read/write actions and views, using Entity Framework' and specify my model a controller is generated that uses one primary key.

My entity has 2 keys which are needed to pull data correctly. I made the necessary adjustments manually but I wanted to make sure I understand this properly before moving forward.

My thinking is that when Microsoft implemented this pattern they thought support for one primary key would be the most likely scenario so they did not support a composite key. Is this correct? If not how can I have the scaffolding template generate controllers that look for both pieces of data?

来源:https://stackoverflow.com/questions/9929991/entity-framework-and-mvc-scaffolding-with-composite-primary-keys

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