When I was trying to run the application I had faced this problem. I resolved by selecting the complete object that result will consists of complete customer objects. But before I selected a subset of the customer objects, just two members.
Problem:
var customerOrders = from customer in db.Customers
where customer.ContactName.StartsWith("C")
orderby customer.ContactName
select new {customer.ContactName, customer.Phone };
I got the following error,
The model item passed into the dictionary is of type'System.Data.Entity.Infrastructure.DbQuery`1[<>
f__AnonymousType2`2[System.String,System.String]]',but this dictionary requires a model item of type
'System.Collections.Generic.IEnumerable`1[LinQTutoris.Models.Customer]'.
Description: Anunhandled exception occurred during the execution of the current web request.Please review the stack trace for more information about the error and where itoriginated in the code.
Exception Details: System.InvalidOperationException:The model item passed into the dictionary is of type'System.Data.Entity.Infrastructure.DbQuery`1[<>f__AnonymousType2`2[System.String,System.String]]',but this dictionary requires a model item of type'System.Collections.Generic.IEnumerable`1[LinQTutoris.Models.Customer]'.
Solution:
edited the code,selecting the complete object of customer
var customerOrders = from customer in db.Customers
where customer.ContactName.StartsWith("C") orderby customer.ContactName
select customer;