title: Everything displays correctly except for the list of products of a category
body: <p>I am making a webpage using ASP.NET Core MVC. It's an online store. The issue I have is that everything displays correctly except for the list of products of a category.</p>
  
  <p>Category and Product have a one-to-many relationship in the SQLite database I am working with. When I list the category, id, name, description.., works superb, but the products in that category don't show.</p>
  
  <p>This is the code where I have the issue. @Model.Products is the correct call, but I tried everything, from transforming it ToList(), ToString(), or searching for the products using a foreach loop:</p>
  
  <pre><code>@model Packt.Shared.Category
  @{
      ViewData["Title"] = "Category Details - " + Model.CategoryName;
  }
  
  &lt;h2&gt;Category Details&lt;/h2&gt;
  &lt;hr/&gt;
  &lt;div class=dl-horizontal&gt;
      &lt;dt&gt;Category ID&lt;/dt&gt;
      &lt;dd&gt;@Model.CategoryID&lt;/dd&gt;
      &lt;dt&gt;Category NAme&lt;/dt&gt;
      &lt;dd&gt;@Model.CategoryName&lt;/dd&gt;
      &lt;dt&gt;Category description&lt;/dt&gt;
      &lt;dd&gt;@Model.Description&lt;/dd&gt;
      &lt;dt&gt;List of products of the category&lt;/dt&gt;
      &lt;dd&gt;@Model.Products&lt;/dd&gt; &lt;!-Here it doesnt show a thing, not even with ToString() nor ToList(), also tried with Async-&gt;&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The button that launchs the code is the View button in the Index.cshtml razor page. How do I call the list of Products in the Category (1-to-many relationship)?:</p>
  
  <pre><code>@model NorthwindMvc.Models.HomeIndexViewModel
  @{
    ViewData["Title"] = "Radical Change";
    string currentItem = "";
  }
  &lt;div id="categories" class="carousel slide" data-ride="carousel" 
       data-interval="3000" data-keyboard="true"&gt;
    &lt;ol class="carousel-indicators"&gt;
    @for (int c = 0; c &lt; Model.Categories.Count; c++)
    {
      if (c == 0)
      {
        currentItem = "active";
      }
      else
      {
        currentItem = "";
      }
      &lt;li data-target="#categories" data-slide-to="@c" 
        class="@currentItem"&gt;&lt;/li&gt;
    }
    &lt;/ol&gt;
    &lt;div class="carousel-inner"&gt;
    @for (int c = 0; c &lt; Model.Categories.Count; c++)
    {
      if (c == 0)
      {
        currentItem = "active";
      }
      else
      {
        currentItem = "";
      }
      &lt;div class="carousel-item @currentItem"&gt;
        &lt;img class="d-block w-100" 
  src="~/images/category@(Model.Categories[c].CategoryID).jpeg" 
          alt="@Model.Categories[c].CategoryName" /&gt;
        &lt;div class="carousel-caption d-none d-md-block"&gt;
          &lt;h2&gt;@Model.Categories[c].CategoryName&lt;/h2&gt;
          &lt;h3&gt;@Model.Categories[c].Description&lt;/h3&gt;
          &lt;p&gt;
            &lt;a class="btn btn-primary" 
  href="/Home/CategoryDetail/@Model.Categories[c].CategoryID"&gt;View&lt;/a&gt;
          &lt;/p&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    }
    &lt;/div&gt;
    &lt;a class="carousel-control-prev" href="#categories" 
      role="button" data-slide="prev"&gt;
      &lt;span class="carousel-control-prev-icon" 
        aria-hidden="true"&gt;&lt;/span&gt;
      &lt;span class="sr-only"&gt;Previous&lt;/span&gt;
    &lt;/a&gt;
    &lt;a class="carousel-control-next" href="#categories" 
      role="button" data-slide="next"&gt;
      &lt;span class="carousel-control-next-icon" 
        aria-hidden="true"&gt;&lt;/span&gt;
      &lt;span class="sr-only"&gt;Next&lt;/span&gt;
    &lt;/a&gt;
  &lt;/div&gt;
  &lt;div class="row"&gt;
    &lt;div class="col-md-12"&gt;
      &lt;h1&gt;Radical Change - Hairdresser&lt;/h1&gt;
      &lt;p class="lead"&gt;
        We've had @Model.VisitorCount visitors this month.
      &lt;/p&gt;
      &lt;form asp-action="ProductsThatCostMoreThan" method="get"&gt;
        &lt;input name="price" placeholder="Enter product price" /&gt;
        &lt;input type="submit" value="Submit" /&gt;
      &lt;/form&gt;
      &lt;form asp-action="Customers" method="get"&gt;
        &lt;input name="country" placeholder="Select a country" /&gt;
        &lt;input type="submit" value="Submit" /&gt;
      &lt;/form&gt;
      &lt;h2&gt;Productos&lt;/h2&gt;
        &lt;div id="newspaper"&gt;
          &lt;ul&gt;
          @foreach (var item in @Model.Products)
          {
            &lt;li&gt;
              &lt;a asp-controller="Home" 
                 asp-action="ProductDetail" 
                 asp-route-id="@item.ProductID"&gt;
              @item.ProductName costs
              @item.UnitPrice.Value.ToString("C")
            &lt;/a&gt;
          &lt;/li&gt;
        }
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>