How can I specify which foreign key column has to be used in the views when scaffolding? Im some cases MVC seems to be smart enough to take the right column from the other table, but atm I am having an issue with one and was wondering if I can somehow tell which value to use when scaffolding.
public class Tafel
{
public virtual int Id { get; set; }
public virtual int TafelNummer { get; set; }
public virtual int AantalPlekken { get; set; }
public virtual int CoordX { get; set; }
public virtual int CoordY { get; set; }
}
This is the model that I am having issue's with, it now shows the Id's in a selectbox, but I want it to show TafelNummer
instead when scaffolding.
Here is a picture that will maybe explain it better --> http://i.imgur.com/p29S1J4.png
Set the attribute DisplayColumn in your model like this:
using System.ComponentModel.DataAnnotations;
[DisplayColumn("TafelNummer")]
public class Tafel
EntityFramework sets the MetaData, it takes f.e. the first string property. With this addition you can change that. You only have to re-scaffold.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With