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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:49:30+00:00 2026-06-14T00:49:30+00:00

I’ve been getting the error The underlying provider failed on Open. recently and I’ve

  • 0

I’ve been getting the error “The underlying provider failed on Open.” recently and I’ve been pulling my hair out trying to figure out why. On closer inspection of the error the inner exception is “The connection was not closed. The connection’s current state is connecting.” and the stack trace is

"at System.Data.ProviderBase.DbConnectionClosedConnecting.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)"

As far as I can tell the error seems to happen at random or possibly when making changes to the application. Any help would be greatly appreciated.

My current setup is

  • IIS Express
  • Microsoft SQL Server Express Edition
  • Visual Studio 2012
  • MVC Web API \ Asp.net MVC 4
  • Entity Framework 5

My data layer is modeled off the Repository pattern and injected via Structure map.

Repository

public class Repository<T> : IDisposable, IRepository<T> where T : class
{
    private readonly DbSet<T> _dbSet;
    private readonly DbContext _dbContext;

    public Repository(IDbContextFactory<MyContext> dbContextFactory)
    {
        _dbContext = dbContextFactory.Create();
        _dbSet = _dbContext.Set<T>();
    }

    //removed for brevitity

    public void Dispose()
    {
        _dbContext.Dispose();
    }

DbContextFactory

public class MyContextFactor : IDbContextFactory<MyContext>, IDisposable
{
    private MyContext _dataContext;

    public MyContextFactor Create()
    {
        return _dataContext ?? (_dataContext = new MyContext());
    }

    public void Dispose()
    {
        _dataContext.Dispose();
    }
}

Structure Map Registry for IOC

For(typeof(IDbContextFactory<MyContext>)).HybridHttpOrThreadLocalScoped().Use(typeof(MyContextFactory));

Connection String

<add name="MyContextConnectionString" connectionString="metadata=res://*/Model.MyProject.csdl|res://*/Model.MyProject.ssdl|res://*/Model.MyProject.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local);initial catalog=MyDB;User Id=SQLUser;Password=****;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>

Things I’ve attempted to fix the problem and so far haven’t worked

  • ensure context is per http context via structure map scope
  • added dispose to repository
  • added dispose to ContextFactory
  • switched from Intergrated Sql auth to Sql authentication
  • 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-14T00:49:31+00:00Added an answer on June 14, 2026 at 12:49 am

    This turned out to be an ActionFilterAttribute that was being cached. The ActionFilterAttribute had a Entity framework context that wasn’t being disposed of correctly and was being shared across requests.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to select an H1 element which is the second-child in its group

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.