2013-04-20 1 views
3

내가 EF 6으로 업그레이드 않았고 내가 할 때 쿼리가이 오류를 보여주고있다 휴관일 :EntityFramework 6 연결

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

코드 :

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)); 
+0

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)); –

답변

0

EF 6 알파 상태에, 일을 할 수 미래의 변화. 나는 이것을 시도하지는 않았지만 아마도 당신은해야만한다. SqlQuery 메소드를 실행하기 전에

db.Database.Connection.Open(); 

을 실행하기 전에 수행해야한다.

+0

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)); –

관련 문제