Im獲取像這樣的錯誤:指定的LINQ表達式包含對與不同上下文關聯的查詢的引用。(Linq/Lambda)使用2個DBContext連接2個或多個表
var employee = new ApplicationDbContext().Employee;
var otherTable = new OtherDbContext().OtherTable;
var returnValue = (from e in employee
join o in otherTable on e.Id equals o.Id
select new
{
e.Name,
e.Address,
o.Others
});
任何解決方案/ s? 謝謝!
我不知道,你可以在兩個上下文加盟。 EF必須以某種方式將其轉換爲SQL查詢 – garryp
不可能同時查詢兩個上下文,請參閱此問題/答案:http://stackoverflow.com/questions/4278993/is-it-possible-to-perform-joins- across-different-databases-using-linq – Terence
Employee或OtherTable中是否有大量數據? –