Hello all.. im complete beginner to MVC, im just stared learning Mvc through a book Hands on mvc.. and in that book a sample project is there.., it is "MovieReview" in which I used EF code first approach..so why im here is that i got exception while im doing that project... it throws an Exception when i run home controler index action "{"The entity or complex type 'MovieReview.Models.MovieViewModel' cannot be constructed in a LINQ to Entities query."}"..
i just upload my solution below MovieReview.rar file... plz Help me anyonee..
Thanks for advancee...

Nilesh SawardekarRank #648 · 3.7K reputationPosted Jul 6, 2016, 9:48 AM EDT
You cannot (and should not be able to) project onto a mapped entity. You can, however, project onto an annonymous type or onto a DTO:
public class ProductDTO { public string Name { get; set; } // Other field you may need from the Product entity }And your method will return a List of DTO's.
public ListProductDTO> GetProducts(int categoryID) { return (from p in db.Products where p.CategoryID == categoryID select new ProductDTO { Name = p.Name }).ToList(); }Shakti Singh DulawatRank #668 · 3.6K reputationPosted Jul 6, 2016, 2:23 AM EDT