For those of you (like me) that wasted too much time from this error:
I had received the same error: "Could not find implementation of query Pattern for source type 'DbSet'" but the solution for me was fixing a mistake at the DbContext level.
When I created my context I had this:
public class ContactContext : DbContext
{
public ContactContext() : base() { }
public DbSet Contacts { get; set; }
}
And my Repository (I was following a Repository pattern in ASP.NET guide) looked like this:
public Contact FindById(int id)
{
var contact = from c in _db.Contacts where c.Id == id select c;
return contact;
}
My issue came from the initial setup of my DbContext, when I used DbSet as a generic instead of the type.
I changed public DbSet Contacts { get; set; }
to public DbSet<Contact> Contacts { get; set; }
and suddenly the query was recognized.
This is probably what k.m says in his answer, but since he mentioned IEnumerable<t>
and not DbSet<<YourDomainObject>>
I had to dig around in the code for a couple hours to find the line that caused this headache.