I have two entities which are generated from data first approach of entity framework in MVC5. Following are the Models
public partial class Cuisine
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Dish> Dishes { get; set; }
}
public partial class Dish
{
public int Id { get; set; }
public string Name { get; set; }
public int CuisineId { get; set; }
public virtual Cuisine Cuisine { get; set; }
}
When I display the Dishes it is showing as below
But I want the column names as Name and Cuisine Name instead of Name and Name. How to do that? I want to display as Name when showing Cuisine list and Cuisine Name when showing in Dish list.
Code for my cshtml
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Cuisine.Name)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Cuisine.Name)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.Id })
</td>
</tr>
}
</table>

[Display(Name = "Cuisine Name")]attribute