I recently migrated an existing project to .net 4.5 and changed out what this project was using for data access (switching to Entity Framework).
For some reason any
I was having the same problem. I tried the following solution to solve the problem
I hope this is resolved :)
The assembly for Queryable (the thing that adds the FirstOrDefault
extension method you are using) is in System.Core
, however it's namespace is System.Linq
, you can see this on the MSDN page for it
Namespace: System.Linq
Assembly: System.Core (in System.Core.dll)
You need to have in your project a refrence to System.Core
and in the file you are trying to use it a using System.Linq;
If you have both of these things double check that your project or some project you are refrencing did not create it's own System.Data.Entity.DbSet<T>
class which does not implement IQueryable<T>
or IEnumerable<T>
.
This question already has an answer but I had a different cause.
I also needed to have a reference to System before First or Default would show up...