问题
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