title: MVC Combine data from two different tables into one view
body: <p>Lately I have been trying to get into MVC. I finished the MVC tutorial on the asp.net website of Microsoft. Now that I am trying to figure out how I should apply the following database design in a model class (C#) code of the application I am working on, I am experiencing certain trouble.</p>
  
  <p>I want to know how I can add a ProductCategory to my model:</p>
  
  <p><a href="https://i.stack.imgur.com/72Qil.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/72Qil.png" alt="Database design"></a></p>
  
  <p>My model class:</p>
  
  <pre><code>namespace myprojectname.Models
  {
      public class ShoppingCartItems
      {
          public virtual int ID { get; set; }
          [Required]
          [Display(Name="Product name")]
          public virtual string ProductName { get; set; }
          //[Display(Name="Category")]
          //public virtual int CategoryName { get; set; }
          [Display(Name="Date")]
          public virtual DateTime DateAdded { get; set; }
          [Required]
          [DataType(DataType.Currency)]
          public virtual decimal ProductPrice { get; set; }
          public virtual int AmountAvailable { get; set; }
      }
  }
  </code></pre>
  
  <p>ShoppingCartItems is what should displays all entries of the products table.
  As far as I know it should be possible to scaffold all of the tables and display all of the products with categories on one page.</p>
  
  <p>Can anyone explain me how such MVC model class (or do I need to add a query to the controller class?) would need to look like in order to show categories on the index view belonging to the products displayed? Should I need to make an object of type Categories and add it to my properties?</p>