title: Does not contain a definition for "Add"
body: <p>I'm trying to make the same thing like in <a href="https://stackoverflow.com/questions/16383494/mvc-4-many-to-many-relation-and-checkboxes">this</a> thread, but I'm getting error:</p>
  
  <blockquote>
    <p>'System.Collections.Generic.IEnumerable' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Create(ANIME anime)
  {
      var db = new MainDatabaseEntities();
      var newanime = new ANIME
      {
          ID_AN = anime.ID_AN,
          TITLE_OR = anime.TITLE_OR,
          TITLE_EN = anime.TITLE_EN,
          GENRES = new List&lt;GENRES&gt;()
      };
  
      foreach (var selectedAnime in anime.GENRES.Where(c =&gt; c.isSelected))
      {
          var genre = new GENRES { ID_GE = selectedAnime.ID_GE };
          db.GENRES.Attach(genre);
          newanime.GENRES.Add(genre); &lt;--- this is the error line
      }
  
      db.ANIME.Add(newanime);
      db.SaveChanges();
      return RedirectToAction("Index");
  }
  </code></pre>
  
  <p>ANIME:</p>
  
  <pre><code>public partial class ANIME
  {
      public int ID_AN { get; set; }
      public string TITLE_OR { get; set; }
      public string TITLE_EN { get; set; }
  
      public virtual IEnumerable&lt;GENRES&gt; GENRES { get; set; }
  }
  </code></pre>
  
  <p>GENRES:</p>
  
  <pre><code>public partial class GENRES
  {
      public int ID_GE { get; set; }
      public string GENRE { get; set; }
      public bool isSelected { get; set; }
      public virtual ICollection&lt;ANIME&gt; ANIME { get; set; }
  }
  </code></pre>
  
  <p>The error is in the line <code>newanime.GENRES.Add(genre)</code> in <code>HttpPost</code>. I added <code>using System.Linq</code> to all models and controllers but it doesn't help. Any ideas how to resolve this?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>After repairing this a new error arrived. I think it's not related to above one but I don't want to spam unnecessary threads.</p>
  
  <p>Error message:</p>
  
  <blockquote>
    <p>The entity or complex type 'MainDatabaseModel.GENRES' cannot be constructed in a LINQ to Entities query.</p>
  </blockquote>
  
  <p>Related code:</p>
  
  <pre><code>public ActionResult Create()
  {
      var db = new MainDatabaseEntities();
      var viewModel = new ANIME
      {
          GENRES = db.GENRES.Select(c =&gt; new GENRES
          {
              ID_GE = c.ID_GE,
              GENRE = c.GENRE,
              isSelected = false
          }).ToList()
      };
      return View(viewModel);       
  }
  </code></pre>