Major Productions
Major Productions

Reputation: 6042

EF4 EntityException - The underlying provider failed on Open

Okay, this is a new one. I'm trying to debug my project, which I've done many times in the past, and I'm now getting this exception in one of my repositories. I haven't seen it before now. I haven't touched my repos in days, and my connection string is the same as its always been. The inner exception states:

{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}

And the code it's choking on is:

public class HGArticleRepository : IArticleRepository
{
    private HGEntities _siteDB = new HGEntities();

    public List<Article> Articles
    {
        get { return _siteDB.Articles.ToList(); } // <-- this is the line
    }

    // more repo code
}

Again, like I said, I've never encountered this exception before, and I haven't touched my domain code in days.

Upvotes: 2

Views: 5098

Answers (2)

Alberto Montellano
Alberto Montellano

Reputation: 6256

A second option of solution: Review that IIS is running. In my case it was stopped, so I got the same error.

Upvotes: 0

Andrey
Andrey

Reputation: 60065

This error usually means:

  1. Connection String points to nonexistent SQL Server.
  2. Connection String points to SQL Server that was shut down. Or not started.
  3. Named pipes transport was disabled in SQL Server settings.

Check them carefully one by one. In your case I guess it is 2.

Upvotes: 8

Related Questions