Mssql Error 'The Underlying Provider Failed on Open'

MSSQL Error 'The underlying provider failed on Open'

I had this error and found a few solutions:

Looking at your connection string, it looks valid. I found this blog post, the problem here is that they were using Integrated Security. If you are running on IIS, your IIS user needs access to the database.

If you are using Entity Framework with Transactions, Entity Framework automatically opens and closes a connection with each database call. So when using transactions, you are attempting to spread a transaction out over multiple connections. This elevates to MSDTC.

(See this reference for more information.)

Changing my code to the following fixed it:

using (DatabaseEntities context = new DatabaseEntities())
{
context.Connection.Open();
// the rest
}

Entity Framework The underlying provider failed on Open

Seems like a connection issue. You can use the Data link properties to find if the connection is fine. Do the following:

  1. Create a blank notepad and rename it to "X.UDL"
  2. Double click to open it
  3. Under connections tab choose the server name/enter the name
    use the correct credentials and DB
  4. Click OK to save it.

Now open the file in Notepad and compare the connection string properties.

The underlying provider failed on Open iis

Based on that connection string, the identity trying to connect to your SQL instance is the user account that is specified in your application's IIS app pool (usually iis apppool\defaultapppool). You'll either need to;

  • allow this account to access the SQL database
  • put the necessary credentials for a SQL account into the connection string
  • set the windows account details on the app pool in order for the application to connect.

What's happening is that when you're debugging, the account used to connect via Integrated Security=True is the currently logged in user account - which is likely set up to allow you to connect to the database, especially if you've installed SQL Server during the setup of your machine (it's the default SQL Server setup config to add the current user). However IIS needs a specific account to run under which isn't the currently logged in user - hence the need for the options above.

MSSQL Error 'The underlying provider failed on Open' using WCF & EntityFramework

Looking at your connection string, it looks valid. I found this blog post, the problem here is that they were using Integrated Security. If you are running on IIS, your IIS user needs access to the database.

If you are using Entity Framework with Transactions, Entity Framework automatically opens and closes a connection with each database call. So when using transactions, you are attempting to spread a transaction out over multiple connections. This elevates to MSDTC.

(See this reference for more information.)

Please read this article:
MSSQL Error 'The underlying provider failed on Open'

Entity Framework The underlying provider failed on Open

Error: The underlying provider failed on Open. How to resolve it?

The underlying provider failed on Open - EF 6.1, MSSQL 2008 r2

my problem (issue) was SQL server Connection pooling :D
the pooling store the last request time and when u idle for while around 5-10 min and then when it receive request it'll answer the request ( !??! ) but after that the pooling terminate your connection and your next request throw the exception :(

for now i set timer to each 30s send a request to DB !



Related Topics



Leave a reply



Submit