For those of you (like me) who have lost too much time due to this error:
I got the same error: "Could not find the implementation of the query template for the source type" DbSet ", but the solution for me was to fix the error 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 followed the repository pattern in the ASP.NET manual) looked like this:
public Contact FindById(int id) { var contact = from c in _db.Contacts where c.Id == id select c; return contact; }
My problem arose because of the initial setup of my DbContext when I used DbSet as generic instead of type.
I changed public DbSet Contacts { get; set; } public DbSet Contacts { get; set; } public DbSet Contacts { get; set; } public DbSet Contacts { get; set; } public DbSet Contacts { get; set; } public DbSet Contacts { get; set; } public DbSet Contacts { get; set; } public DbSet Contacts { get; set; } public DbSet Contacts { get; set; } public DbSet<Contact> Contacts { get; set; } public DbSet<Contact> Contacts { get; set; } public DbSet<Contact> Contacts { get; set; } public DbSet<Contact> Contacts { get; set; } public DbSet<Contact> Contacts { get; set; } public DbSet<Contact> Contacts { get; set; } public DbSet<Contact> Contacts { get; set; } public DbSet<Contact> Contacts { get; set; } public DbSet<Contact> Contacts { get; set; } and suddenly the request was recognized.
This is probably what km says in his answer, but since he mentioned IEnumerable<t> and not DbSet<<YourDomainObject>> I had to dig into the code for a couple of hours to find the line that caused this headache.
TylerSmall19 Jun 17 '18 at 0:23 2018-06-17 00:23
source share