title: Getting IEnumerable Error: CS1061 does not contain C# ASP.NET MVC5
body: <p>I couldn't find a solution for my issue, I have tried many alternatives but I could not resolve it.</p>
  
  <p>I generate my database with the model first, afterwards I have used Scaffolding to generate the Views (Index, Create, Edit, Delete..). The only view (Index) with the model use IEnumerable.</p>
  
  <p>The Index View was :</p>
  
  <pre><code>@model IEnumerable&lt;CAD_CMDBv2.Models.Location&gt;
  
  @{
      ViewBag.Title = "Location's Management";
  }
  
  &lt;h2&gt;All Locations&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create Location", "Create")
  &lt;/p&gt;
  
      &lt;table class="table"&gt;
           &lt;tr&gt;
                &lt;th&gt;
                      @Html.DisplayNameFor(model =&gt; model.Location.site_name)
                &lt;/th&gt;
                &lt;th&gt;
                      @Html.DisplayNameFor(model =&gt; model.Location.country_name)
                &lt;/th&gt;
                &lt;th&gt;
                      @Html.DisplayNameFor(model =&gt; model.Location.region_name)
                &lt;/th&gt;
                &lt;th&gt;&lt;/th&gt;
          &lt;/tr&gt;
  
          @foreach(var item in Model) {
              &lt;tr&gt;
                   &lt;td&gt;
                        @Html.DisplayFor(modelItem =&gt; item.Location.site_name)
                   &lt;/td&gt;
                   &lt;td&gt;
                        @Html.DisplayFor(modelItem =&gt; item.Location.country_name)
                   &lt;/td&gt;
                   &lt;td&gt;
                        @Html.DisplayFor(modelItem =&gt; item.Location.region_name)
                   &lt;/td&gt;
                   &lt;td&gt;
                        @Html.ActionLink("Edit", "Edit", new { id = item.Location.location_id }) |
                        @Html.ActionLink("Details", "Details", new { id = item.Location.location_id }) |
                        @Html.ActionLink("Delete", "Delete", new { id = item.Location.location_id })
                   &lt;/td&gt;
             &lt;/tr&gt;
             }
       &lt;/table&gt;
  </code></pre>
  
  <p>I want to insert an asynchronous form for the datasearch, so that becomes:</p>
  
  <pre><code>@model IEnumerable&lt;CAD_CMDBv2.Models.RechercheLocationViewModel&gt;
  
  @{
      ViewBag.Title = "Location's Management";
  }
  
  &lt;h2&gt;All Locations&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create Location", "Create")
  &lt;/p&gt;
  
  @using (Html.BeginForm("Search", "Restaurant", FormMethod.Get))
  {
      @Html.TextBoxFor(r =&gt; r.Recherche)
      &lt;input type="submit" value="Rechercher" /&gt;
  
      &lt;p&gt;Search Results &lt;/p&gt;
      if (Model.ListeLocations.Count == 0)
      {
          &lt;p&gt; No Results but you can create it !&lt;/p&gt;
      }
      else
      {
          &lt;table class="table"&gt;
              &lt;tr&gt;
                  &lt;th&gt;
                      @Html.DisplayNameFor(model =&gt; model.Location.site_name)
                  &lt;/th&gt;
                  &lt;th&gt;
                      @Html.DisplayNameFor(model =&gt; model.Location.country_name)
                  &lt;/th&gt;
                  &lt;th&gt;
                      @Html.DisplayNameFor(model =&gt; model.Location.region_name)
                  &lt;/th&gt;
                  &lt;th&gt;&lt;/th&gt;
              &lt;/tr&gt;
  
          @foreach(var item in Model) {
              &lt;tr&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.Location.site_name)
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.Location.country_name)
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.Location.region_name)
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.ActionLink("Edit", "Edit", new { id = item.Location.location_id }) |
                      @Html.ActionLink("Details", "Details", new { id = item.Location.location_id }) |
                      @Html.ActionLink("Delete", "Delete", new { id = item.Location.location_id })
                  &lt;/td&gt;
              &lt;/tr&gt;
          }
          &lt;/table&gt;
      }
  }
  </code></pre>
  
  <p>I have modified the model in adding a View Model class to allow in IndexView to take as model the View Model by taking over the parameters Locations and use the Search parameter:</p>
  
  <pre><code>//------------------------------------------------------------------------------
  // &lt;auto-generated&gt;
  //     Ce code a été généré à partir d'un modèle.
  //
  //     Des modifications manuelles apportées à ce fichier peuvent conduire à un comportement inattendu de votre application.
  //     Les modifications manuelles apportées à ce fichier sont remplacées si le code est régénéré.
  // &lt;/auto-generated&gt;
  //------------------------------------------------------------------------------
  
  namespace CAD_CMDBv2.Models
  {
      using System;
      using System.Collections;
      using System.Collections.Generic;
      using System.ComponentModel.DataAnnotations;
      public partial class Location
      {
          [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
          public Location()
          {
              this.User = new HashSet&lt;User&gt;();
              this.host = new HashSet&lt;Host&gt;();
              this.client_catia = new HashSet&lt;Client_catia&gt;();
              this.client_smartam = new HashSet&lt;Client_smarteam&gt;();   
          }
  
          public int location_id { get; set; }
          [Display(Name = "Site's Name")]
          public string site_name { get; set; }
          [Display(Name = "Country's Name")]
          public string country_name { get; set; }
          [Display(Name = "Region's Name")]
          public string region_name { get; set; }
  
          [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
          public virtual ICollection&lt;User&gt; User { get; set; }
          [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
          public virtual ICollection&lt;Host&gt; host { get; set; }
          [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
          public virtual ICollection&lt;Client_catia&gt; client_catia { get; set; }
          [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
          public virtual ICollection&lt;Client_smarteam&gt; client_smartam { get; set; }    
      }
      public class RechercheLocationViewModel : IEnumerable&lt;Location&gt; {
          public string Recherche {get; set;}
          public Location Location { get; set; }
          public List&lt;Location&gt; ListeLocations;
  
          public IEnumerator&lt;Location&gt; GetEnumerator()
          {
              return ListeLocations.GetEnumerator();
          }
  
          IEnumerator IEnumerable.GetEnumerator()
          {
              return ListeLocations.GetEnumerator();
          }
      }   
  }
  </code></pre>
  
  <p>The current Controller    </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data;
  using System.Data.Entity;
  using System.Linq;
  using System.Net;
  using System.Web;
  using System.Web.Mvc;
  using CAD_CMDBv2.Models;
  
  
  namespace CAD_CMDBv2.Areas.Locations.Controllers
  {
      public class LocationsController : Controller
      {
          private ModeleDonneesCMDBContext db = new ModeleDonneesCMDBContext();
  
          // GET: Locations/Locations
          public ActionResult Index()
          {
              var liste =  db.Locations.ToList();
              var listeTriee = liste.OrderBy(t =&gt; t.site_name);
  
              return View(listeTriee);
          }
          ...
  </code></pre>
  
  <p>But that generates two errors of the same type about IEnumerable in the Index View on the lines:</p>
  
  <pre><code>@Html.TextBoxFor(r =&gt; r.Recherche)
  </code></pre>
  
  <p>And</p>
  
  <pre><code>if (Model.ListeLocations.Count == 0)
  </code></pre>
  
  <p>I got this error:</p>
  
  <blockquote>
    <p>CS1061 Error  'IEnumerable' does not contain
    a definition for 'ListeLocations' and no extension method
    'ListeLocations' accepting a first argument of type
    'IEnumerable' could be found (are 
    you missing a using directive or an assembly reference ?)</p>
  </blockquote>
  
  <p>What does that mean? How can I resolve this? I still have some difficulty with understanding the IEnumerable interface.</p>