title: What is meant by 'The specified LINQ expression contains references to queries that are associated with different contexts'
body: <p>I have the following Action method:-</p>
  
  <pre><code>public ActionResult Index(string searchTerm=null, int page = 1)
          {
              var racks = repository.AllFindRacks(searchTerm).OrderBy(a=&gt;a.Technology.Tag).ToPagedList(page, 5) ;
  
              if (Request.IsAjaxRequest())
              {
  
                  return PartialView("_RackTable", racks);
              }
              return View(racks);
          }
  </code></pre>
  
  <p>And the following Repository method:-</p>
  
  <pre><code>public IQueryable&lt;RackJoin&gt; AllFindRacks(string q)
          {
              List&lt;RackJoin&gt; rakjoin = new List&lt;RackJoin&gt;();
              var result = from rack in tms.TMSRacks
             .Include(rack =&gt; rack.DataCenter)
             .Include(rack =&gt; rack.Zone)
             .Include(rack =&gt; rack.TMSFirewalls)
             .Include(rack =&gt; rack.TMsRouters)
             .Include(rack =&gt; rack.TMSServers)
             .Include(rack =&gt; rack.TMSStorageDevices)
             .Include(rack =&gt; rack.TMSSwitches)
             .Include(rack =&gt; rack.Technology)
                           join resource in entities.Resources
                           .Include(a =&gt; a.ComponentDefinition)
                             .Include(a =&gt; a.ResourceLocation.SiteDefinition.SDOrganization)
                             .Include(a =&gt; a.ResourceLocation.SiteDefinition.AccountDefinition.SDOrganization)
                           on rack.Technology.IT360ID equals resource.RESOURCEID
                           where (q == null || rack.Technology.Tag.ToUpper().StartsWith(q.ToUpper()))
                           select new RackJoin { 
                           Rack = rack,
                           Resource = resource,
                           Customer = resource.ResourceLocation.SiteDefinition.AccountDefinition.SDOrganization,
                           Site = resource.ResourceLocation.SiteDefinition.AccountDefinition.SDOrganization,
                           Technology = rack.Technology
  
                           };
              return result;
  
          }
  </code></pre>
  
  <p>But when i called the Action method i am getting the following exception :-</p>
  
  <blockquote>
    <p>System.NotSupportedException was unhandled by user code<br>
    HResult=-2146233067   Message=The specified LINQ expression contains
    references to queries that are associated with different contexts.<br>
    Source=System.Data.Entity   StackTrace:</p>
  </blockquote>