title: Entity Framework 5 MVC 4 - Scaffolding Error - no key
body: <p>Firstly i have to say i am a complete novice with MVC and EF. I have created Model using Database First, and selected two table Users ---> User Detail (related)</p>
  
  <p>The models are generated fine, they validate fine and if i try do simple data access this works fine too. </p>
  
  <p>Now when i try combine this with MVC 4 scaffolding and selected new controllers/EF framework add/update/delete etc, I put in User Model + UserContext it complains that the auto-generated Model has no key.</p>
  
  <p>Entity Type - "User" has not key. So i open the Model and see that in fact there is a key, and it has the check box Entity key ticked, as well as the little "key" sign next to the property.</p>
  
  <p>I have looked everywhere the only solution that works is to manually open up the User.cs and put the [Key] attribute next to the key - this to me is scary because this file is clearly autogenerated and i would not want to have to do this for every key? am i doing something wrong?</p>
  
  <p>Never the less i digress, now that i have added the key to both User and UserDetails cs files, it stops complaining and now starts complaining about:</p>
  
  <p>Unable to retrieve MetaData: for User. Unable to determine the principle end of an association between User and UserDetail. The principle end of this association must be explicitly configured using either the relationship fluent API or data annotations. </p>
  
  <p>I have two questions now:</p>
  
  <ol>
  <li>should i be messing with the autogenerated files like this? or am i doing something wrong?
  2/ How do i solve this second issue? </li>
  </ol>
  
  <p>I feel like something is wrong because i shouldn't be hitting problem after problem like this?</p>