title: Asp.Net MVC C# Additional information: The entity or complex type cannot be constructed in a LINQ to Entities query
body: <p>I get this error: <code>The entity or complex type 'ebs.Models.ExtraItemVM' cannot be constructed in a LINQ to Entities query.</code> on this line:</p>
  
  <pre><code> booking.ExtraItemsVM = extralist.ToList(); 
  </code></pre>
  
  <p>I've seen other examples of this, where it says you get this error if you try to map to actual database tables.</p>
  
  <p>In my case, I'm trying to map to a ViewModel.</p>
  
  <p>My controller code is below.</p>
  
  <p>Firstly get a list of "extras" from the database:</p>
  
  <pre><code> // get a list of extras
   var extralist = db.Extras.Where(x =&gt; x.hotel_id == AccID)
      .Select(e =&gt; new ExtraItemVM
       {
        eID = e.additem_id,
        Description = e.additem_text,
        Price = e.additem_cost,
        Count = 0
       });
  </code></pre>
  
  <p>Then create a new "booking" view model, and try to attach the list of extras to the Booking.ExtraItemsVM property fails:</p>
  
  <pre><code> Booking booking = new Booking();
   booking.ExtraItemsVM = extralist.ToList();        
  </code></pre>
  
  <p><strong>ViewModels*</strong></p>
  
  <pre><code> public class Booking
   {
      public int ID { get; set; }
      public bool HasResults { get; set; }
      public List&lt;ExtraItemVM&gt; ExtraItemsVM { get; set; }
    ...
    ...
   }
  
  public class ExtraItemVM
  {
      public int ID { get; set; }
      public long eID { get; set; }
      public string Description { get; set; }
      public decimal Price { get; set; }
      public int Count { get; set; }
  }
  </code></pre>
  
  <p><strong>Database Model</strong></p>
  
  <pre><code>public class Extra
  {
      [Key]
      [Display(Name = "ID")]
      public long additem_id { get; set; }
      public long hotel_id { get; set; }
      public string additem_text { get; set; }
      public decimal additem_cost { get; set; }
   }
  </code></pre>
  
  <p>I don't think I'm mapping to the database table - so can anyone please help show what I've done wrong please?</p>
  
  <p>Thank you,</p>
  
  <p>Mark</p>