The error message indicates that CodySolutionEntities
is not derived from ObjectContext
, which is a problem because the CompiledQuery
only works with an ObjectContext
. In this case CodySolutionEntities
must be derived from a DbContext
object which, at this time, is the recommended context object to use.
The CompiledQuery
probably worked in the past because, Entity Framework versions prior to 4.1 created an object derived from ObjectContext
instead of DbContext
for you to manage your entities.
Like this post explains, if you're able to target .NET 4.5 you can use EF 5, and you won't need the CompiledQuery
anymore as it will automatically cache compiled LINQ to Entity queries for you. If not you may want to look into switching back to using an ObjectContext
, but before doing that make sure your mindset isn't simply compiled or bust.