Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7800727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:43:51+00:00 2026-06-02T00:43:51+00:00

I am having some issues doing joins in EF using my service layer. Whenever

  • 0

I am having some issues doing joins in EF using my service layer. Whenever I try to do a join I get the following error:

“The specified LINQ expression contains references to queries that are associated with different contexts“

I have spent countless hours trying to figure this out. Most of the articles I have seen deal with joining entity sets from different contexts. However this is happening to me using the same DB. What am I doing wrong?

Example code:

 public virtual IList<ProductVariantAttribute> GetProductVariantAttributes(int ProductID)
     {
         var query = from pva in _productVariantAttributeRepository.Table
                     join b in _productAttributeRepository.Table on pva.ProductAttributeID equals b.ProductAttributeID
                     where pva.ProductID == ProductID
                     select pva;

         var productVariantAttributes = query.ToList();
        return productVariantAttributes;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:43:53+00:00Added an answer on June 2, 2026 at 12:43 am

    This has nothing to do with databases. It has everything to do with instances of ObjectContext.

    You are referencing two different repositories in your query. I guess each of them is wrapping an EntityContext. This will cause this message.

    It is also an anti-pattern. I recommend that you open exactly one EntityContext per HTTP-request or per WCF call or whatever your unit of work is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues in doing a simple regex using sed. I've to do
I'm having some issues using rails validation on a form. What I'm doing is,
I'm having some issues aligning the header text of a datagrid. I'm using an
I am learning c++, and I am having issues doing some newbie things. I
Greetings, I am having some issues with using a bool operation within a Where
I am having some issues with nested models in a form, using Rails 3.1rc4.
I'm trying to get started with FMOD but I'm having some issues compiling the
I'm having some timeout issues with my WCF services. I've been doing load-testing on
I'm building a monitor app and am having some threading issues. I have, using
I am having issues doing a string replacement in Notepad++, and need some help.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.