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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:19:41+00:00 2026-05-25T00:19:41+00:00

I have an ASP.NET MVC 3 application and in my project I use ADO.NET

  • 0

I have an ASP.NET MVC 3 application and in my project I use ADO.NET Entity Data Model.

For access to data I use intermediate class (DataManager):

public class DataManager
{
    private static mrhomeEntities _dataContext;

    public DataManager()
    {
        _dataContext = new mrhomeEntities();
    }

    private OptionStorageRepository _optionStorageRepository;

    public OptionStorageRepository OptionStorage
    {
        get { return _optionStorageRepository ?? (_optionStorageRepository = new OptionStorageRepository(_dataContext)); }
    }
}

In OptionStorageRepository class I have 1 method that returns a list of options:

    public IQueryable<OptionStorage> List()
    {
        return _dataContext.OptionStorage;
    }

Such classes I have more than 15 (with this structure) to get and edit data in database.

Still I have my ControllerFabrick, where I pass a new object of DataManager class:

public class ControllerFabricFactory : DefaultControllerFactory 
{
    protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
    {
        return Activator.CreateInstance(controllerType, new DataManager()) as IController;
    }
}

Also I registered my controller fabrick in Global.asax like this:

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);
        ControllerBuilder.Current.SetControllerFactory(new ControllerFabricFactory());
    }

And in all Controllers I receive this parameter in constructor and using in my action methods:

public class HomeController : Controller
{
    private readonly DataManager dm;

    public HomeController(DataManager dm)
    {
        this.dm = dm;
    }
    [HttpGet]
    public ActionResult Main()
    {
        Page page = dm.Page.Details(mainPageName);

        PageNews pageNews = new PageNews();
        pageNews.page = page;
        pageNews.NewsList = dm.News.List(5);
        pageNews.PopularProject = dm.Project.GetPopularProject();

        if (pageNews.PopularProject != null)
        {
            var list = pageNews.PopularProject.ProjectPictures.Where(p => p.ProjectPictureTypes.Id == 1).ToList();
            if (list.Count > 0)
            {
                ViewData["img"] = list[0].ThumbPath;
            }
        }
        foreach (var item in dm.Page.List())
        {
            ViewData[item.Name] = item.ShortPageText;
        }
        ViewData["projects"] = dm.Project.GetMainPageProjects();
        ViewData["MainText"] = dm.Page.Details("maintext").PageText;
        return View(pageNews);
    }
}

And my question:

When I test my application in web browser I have strange errors, that contains information about connection to database or retrieving data, I have collection of my errors below:

  • The connection was not closed. The connection’s current state is
    connecting.
  • Invalid attempt to read when no data is present
  • ExecuteReader requires an open and available Connection. The
    connection’s current state is open.
  • New transaction is not allowed because there are other threads
    running in the session.
  • An item with the same key has already been added.

Maybe I used wrong structure for get the data?

  • 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-25T00:19:42+00:00Added an answer on May 25, 2026 at 12:19 am

    Per question:

    Update: problem resolved, object DataContext was static (

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

Sidebar

Related Questions

I have asp.net mvc 4 web application project on my server in IIS Directory.
I have an ASP.NET MVC application with a separate project added for tests. I
I have an ASP.NET MVC 2 application. Web project contains a reference to SomeProject
I have a working ASP.NET MVC 3 application. The project is built with VS
I have an ASP.Net MVC 3 application that runs fine when I use the
In my ASP.NET MVC application, I have a project that contains all the business
I have the following project solution: There is a ASP.NET MVC Web Application where
I'm working on an ASP.NET MVC 2 application and use a seperate class library
Say I have an application with the following structure. // ASP.NET MVC (Web Project)
I have a project consisting of three projects, WCF service Asp.net MVC 3 application

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.