3

I did upgrade to the EF 6 and when I do this query is showing this error:

ExecuteReader requires an open and available Connection. The connection's current state is closed.

Code:

var db = new Entity2Entities(); db.Configuration.LazyLoadingEnabled = true; var ids = db.PersonBase.SqlQuery(Utils.Query(param, "PersonBase")) .Select(x => x.Id); var result = db.Employee.Where(x => ids.Contains(x.Id)); 
1
  • db.Configuration.LazyLoadingEnabled = true; var ids = db.PersonBase.SqlQuery(Utils.Query(param,"PersonBase")).Select(x => x.Id); db.Database.Connection.Open(); var result = db.Employee.Where(x => ids.Contains(x.Id)); Commented Apr 20, 2013 at 17:07

1 Answer 1

1

EF 6 is in alpha state, things can change in the future. I didnt try this but maybe you have to do

db.Database.Connection.Open(); 

before executing SqlQuery method.

Sign up to request clarification or add additional context in comments.

1 Comment

db.Configuration.LazyLoadingEnabled = true; var ids = db.PersonBase.SqlQuery(Utils.Query(param, "PersonBase")).Select(x => x.Id); db.Database.Connection.Open(); var result = db.Employee.Where(x => ids.Contains(x.Id));

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.