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 6964465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:55:42+00:00 2026-05-27T15:55:42+00:00

I am building a .NET 4.0 MVC3 app. I use Entity Framework 4.1 and

  • 0

I am building a .NET 4.0 MVC3 app. I use Entity Framework 4.1 and Ninject to inject my repository to controllers:

Bind(Of IDataContext).To(Of DataContext)().InRequestScope()

I have a controller with action that utilizes MyObject’s (POCO entity) static function and pass a repository object to it. This function is supposed to check whether a db object is filled with correct data or not (and return Boolean):

Dim isComplete as Boolean = MyObject.IsComplete(_context, id, qid)

IsComplete (it is a dummy for now) function looks as follows:

Public Shared Function IsComplete(context As IDataContext, id As Integer, qid As Integer) As Boolean
    Dim lookUp As Lookup(Of Integer, Integer) =
    context.QuestionBlockAnswers.Where(Function(m) (m.BlockId = id AndAlso m.QuestionAnswer.QuestionField.Question.QuestionGroup.QuestionnaireVersion.QuestionnaireId = qid)).ToLookup(Function(m) m.QuestionAnswer.QuestionField.Question.Id, Function(m) m.QuestionAnswerId)
    Return True
End Function

As you can see it only initializes a lookUp variable and returns true. The problem is that this lookUp gives my hard times. If I call the action (I use ajax call in this case), I receive an error:

[InvalidOperationException]: There is already an open DataReader associated with this Command which must be closed first.

If i comment the initialization of the lookUp variable I do not get the error anymore. It’s also not a problem with passing the context as a parameter to a static function, because I do it for some other objects and it works fine. It fails only in this case when ToLookup is used.

Do you have any ideas how I can fixed this problem?

  • 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-05-27T15:55:42+00:00Added an answer on May 27, 2026 at 3:55 pm

    You need to add MultipleActiveResultSets=true; to your connection string.

    This is a requirement for EF to work properly .

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

Sidebar

Related Questions

I'm building ASP.NET MVC2 application, and using Entity Framework as ORM. I am having
I am building an MVC3 web app and new to .NET and programming in
I am building an asp.net mvc3 application and I have decided to use areas
I am building a Web application using MVC3 .NET The app should somehow keep
I'm building a simple multi-user (multi-tenant?) App with ASP.NET MVC3 and EF4, one database,
I've been building .NET web applications for many years now, and I never use
Spring.NET is an open source application framework that makes building enterprise .NET applications easier.
I am building an ASP.NET MVC 3 app which will run in Azure. Everything
I am building an ASP.NET MVC3 computer support ticketing portal. There is a maintenance
I'm building an ASP.NET MVC3 Website with EF and DB First Approach. I need

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.