LINQ to Entities does not recognize the method 'System.Linq.IQueryable

ASP.NETErrorsWeb Development

Hi everyone,

I ran into the following error today while attempting to use a raw query with entity framework:

LINQ to Entities does not recognize the method ‘System.Linq.IQueryable…method, and this method cannot be translated into a store expression

I was using FromQuery, and while I’m not too sure what was causing the issue, switching to SqlQuery resolved it:

// Original code
var carList = resp.Db.Cars.FromSql(“SELECT * FROM cars”);

// Changed code
var carList = resp.Db.Cars.SqlQuery(“SELECT * FROM cars”);

Hopefully that’s able to help out anyone else with the issue.

Thanks,
Chris

1 comment

Comments from the original blog are preserved here. New comments are closed.

  1. Ross Acheson

    Wow wow wow yes yes yes this is great. Was banging my head against FromSql for a long time. SqlQuery works great!