title: MVC 5 ERROR but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
body: <p>I am new to Ninjet and Mvc. I know that error mean I am passing the wrong type to the view. but I can't figure out where is the error. here are my classes</p>
  
  <pre><code> public class ProdListViewModel
  {
      public ProdListViewModel()
      {
          this.ProductsList = new List&lt;ProdViewModel&gt;();
      }
      public ProdListViewModel(List&lt;product&gt; products)
      {
          this.ProductsList = new List&lt;ProdViewModel&gt;();
  
          foreach (var prod in products)
          {
              this.ProductsList.Add(new ProdViewModel(prod));
  
  
          }
  
      }
  
      public List&lt;ProdViewModel&gt; ProductsList { get; set; }
  }
  
   public class ProdViewModel
  {
      [Key]
      public int productsID { get; set; }
  
      [Required]
      [StringLength(50)]
      public string pname { get; set; }
  
      public ProdViewModel()
      {
      }
  
      public ProdViewModel(product product)
      {
          productsID = product.productsID;
          pname = product.pname;
  
      }
  }
  </code></pre>
  
  <p>this is my control. as you can see I am using ninjet. I check I am returning to product a list of 2 product. but </p>
  
  <pre><code>    public class ProductController : ControllerBase
  {
       internal readonly IProductRepository productRepository;
  
  
       public ProductController(IProductRepository productRepository)
      {
          this.productRepository = productRepository;
      }
      // GET: Product
      public ActionResult FrontPageList()
  
      {
  </code></pre>
  
  <p>//here I get the product from repository and bring only 2
              var product = productRepository.Products.Take(2).OrderBy(p => p.productsID).ToList();</p>
  
  <pre><code>        return View(new ProdListViewModel(product));
      }
  }
  </code></pre>
  
  <p>here is the view I generate by VS</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>@model IEnumerable&lt;SalesRep.Domain.ViewModels.TuscanyWeb.ProdListViewModel&gt;
  
  @{
      ViewBag.Title = "FrontPageList";
  }
  
  &lt;h2&gt;FrontPageList&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  
  @foreach (var item in Model) {
      &lt;tr&gt;
          &lt;td&gt;
              @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
              @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
              @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  
  &lt;/table&gt;
  </code></pre>
  
  <p>this is the complete error
  The model item passed into the dictionary is of type 'SalesRep.Domain.ViewModels.TuscanyWeb.ProdListViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[SalesRep.Domain.ViewModels.TuscanyWeb.ProdListViewModel]'</p>
  
  <p>on the other hand if in the controller I to this</p>
  
  <pre><code>//List&lt;ProdViewModel&gt; basicObjectList =
          //     product.ConvertAll(x =&gt; new ProdViewModel
          //     {
          //         pname = x.pname,
          //          productsID = x.productsID
          //     });
  </code></pre>
  
  <p>and pass basicObjectList to the view i works fine. </p>