Migrating old Entity Framework 4.x ObjectQuery objects to Entity Framework 6.x era
Posted: (EET/GMT+2)
I was recently migrating older C# code that uses Entity Framework 4.0 to the newest Entity Framework 6.x version, and generally speaking, this process is smooth, and for most part, mechanical work.
However, there are some query constructs that appear to work – as far as the compiler is concerned – but will generate runtime exceptions once you run the application. This happens especially related to the old ObjectQuery class.
It appears that often the easiest solution to replace ObjectQuery references is to replace them with IQueryable
Although it's hard to give exact instructions for each possible case, I wanted to share this piece of wisdom early on. Hope this helps!