title: Add one more property to default Index.cshtml RazorPages Asp.Net Core 2.1.0
body: <p>I am using <code>Asp.Net Core 2.1.0</code> in a project where I want to add one extra <code>property</code> to default scaffolding <code>Index.cshtml</code> page.</p>
  
  <p>Here is my Entities Please suggest.</p>
  
  <pre><code>public class Role
  {
      public int RoleId { get; set; }
      public string RoleName { get; set; }
  
      public ICollection&lt;UserRole&gt; UserRole { get; set; }
  }
  public class User
  {
      [DatabaseGenerated(DatabaseGeneratedOption.None)]
      public string UserName { get; set; }
      public string Password { get; set; }
      public string MobileNumber { get; set; }
      public string Email { get; set; }
  
      public ICollection&lt;UserRole&gt; UserRole { get; set; }
  }
  public class UserRole
  {    
      public int Id { get; set; }
      public string UserName { get; set; }
      public int RoleId { get; set; }
  
      [ForeignKey("RoleId")]
      public Role Role { get; set; }
      [ForeignKey("UserName")]
      public User User { get; set; }
  }
  </code></pre>
  
  <p>Now, the default scaffolding <code>Index.cshtml</code> displays <code>RoleID</code> and <code>UserName</code>where as i want to add one more coloumn i.e <code>RoleName</code> which is available at <code>Role entity</code>.</p>
  
  <p>List should be <code>RoleID, RoleName, UserName</code></p>
  
  <p>Here is my scaffolding page model.</p>
  
  <pre><code>public class IndexModel : PageModel
  {
      private readonly Test.Models.TestContext _context;
  
      public IndexModel(Test.Models.TestContext context)
      {
          _context = context;
      }
  
      public IList&lt;UserRole&gt; UserRole { get;set; }
  
      public async Task OnGetAsync()
      {
          UserRole = await _context.UserRole
              .Include(u =&gt; u.Role)
              .Include(u =&gt; u.User).ToListAsync();
      }
  }
  </code></pre>
  
  <p>Please help me out without disturbing any other pages such as <code>Edit, Detail, Delete.</code></p>
  
  <p>Update: Code in Index.cshtml</p>
  
  <pre><code>    @page
  @model Test.Pages.UserRoles.IndexModel
  
  @{
      ViewData["Title"] = "Index";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;p&gt;
      &lt;a asp-page="Create"&gt;Create New&lt;/a&gt;
  &lt;/p&gt;
  &lt;table class="table"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.UserRole[0].Role)
              &lt;/th&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.UserRole[0].User)
              &lt;/th&gt;
              &lt;th&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach (var item in Model.UserRole)
          {
              &lt;tr&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.Role.RoleId)
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.User.UserName)
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;a asp-page="./Edit" asp-route-id="@item.Id"&gt;Edit&lt;/a&gt; |
                      &lt;a asp-page="./Details" asp-route-id="@item.Id"&gt;Details&lt;/a&gt; |
                      &lt;a asp-page="./Delete" asp-route-id="@item.Id"&gt;Delete&lt;/a&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          }
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>