title: Entity Framework, Razor, DB first: Change column used for foreign key dropdown texts
body: <p>I'm setting up a simple web with Razor controllers to use as an in-house GUI for interfacing with parts of our database. For the most part this goes smoothly, however when it comes to foreign keys, apparently the first column of the referenced table (when sorted alphabetically) becomes the default representation (i.e. what's shown in the drop down box when editing).</p>
  
  <p>As an example, I have a <code>Campaigns</code> table which has a foreign key to <code>Companies</code>. There is a <code>Companies.Name</code> column which I'd like to be used when displaying <code>Campaigns.CompanyId</code>. However, Razor apparently autopicks the first available, using <code>Companies.AccessKey</code> (which is pretty unintelligible) to represent the company.</p>
  
  <p>I'm looking for some way to specify which columns are used for representing a row, hopefully without altering the auto generated files.</p>
  
  <p>This is driving me nuts, and although I would assume it's a common issue, for some reason my googling doesn't drum up any answers :(</p>