The underlying provider failed on Open exception

Discussion of issues, suggestions and bugs of LINQ Insight, Visual Studio add-in for design-time executing LINQ statements, that simplifies debugging LINQ
Post Reply
Thenrich
Posts: 105
Joined: Sun 21 Dec 2014 19:47

The underlying provider failed on Open exception

Post by Thenrich » Sun 10 May 2020 06:27

I have a test code like this:

Code: Select all

using (CustomerEntities context = new CustomerEntities())
            {
                var test = context.Customers.Select(x => x.CustomerNumber == customerNumber);
            }
I am getting this exception in Linq Interactive window. Why? I don't get this exception when I run it in Visual Studio.

Message: The underlying provider failed on Open.
Type: System.Data.Entity.Core.EntityException
Source: EntityFramework
Site: Open
Stack Trace:
at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
at Devart.LinqInsight.Implementation.DataDump.AisQGNjHNq(IEnumerable )

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: The underlying provider failed on Open exception

Post by Shalex » Tue 12 May 2020 16:46

There should be an inner exception. Specify its message and full stack trace.

Thenrich
Posts: 105
Joined: Sun 21 Dec 2014 19:47

Re: The underlying provider failed on Open exception

Post by Thenrich » Tue 12 May 2020 18:50

This is a text message in the Linq interactive window. How do you view the inner exception in there?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: The underlying provider failed on Open exception

Post by Shalex » Wed 13 May 2020 10:51

The inner exception should be in the same window just after the error you have specified.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: The underlying provider failed on Open exception

Post by Shalex » Wed 13 May 2020 20:42

Additional question: is the Target framework of your project .NET Framework or .NET Core?

Thenrich
Posts: 105
Joined: Sun 21 Dec 2014 19:47

Re: The underlying provider failed on Open exception

Post by Thenrich » Wed 13 May 2020 22:03

.NET Framework

Thenrich
Posts: 105
Joined: Sun 21 Dec 2014 19:47

Re: The underlying provider failed on Open exception

Post by Thenrich » Thu 14 May 2020 02:47

So the inner exception was there. I just had to scroll down. It's trying to attach to an mdf file which not correct. It's supposed to be using a SQL Server instance.

When I click on Edit connection string, I get this dialog.
Image

Five fields to enter and it's not clear what to enter. The help file has a totally different dialog which I can understand!
I entered a connection string in the data connection string and got an error that the password string is not supported.
What do I need to enter in the fields? Do you have an example?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: The underlying provider failed on Open exception

Post by Shalex » Fri 22 May 2020 16:26

Could you please send us a small test project so that we can reproduce the issue in our environment?

Thenrich
Posts: 105
Joined: Sun 21 Dec 2014 19:47

Re: The underlying provider failed on Open exception

Post by Thenrich » Fri 22 May 2020 16:30

I am not sure if it's feasible to create one as our project is very big with libraries involved for database connection.

You didn't reply to my question for what to enter in the fields for the database dialog and that your documentation doesn't explain what to enter.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: The underlying provider failed on Open exception

Post by Shalex » Mon 25 May 2020 18:12

If a default constructor includes a connection string or there is a connection string with the same name as context name in app.config, LINQ Insight should pick up the connection string automatically.
You didn't reply to my question for what to enter in the fields for the database dialog and that your documentation doesn't explain what to enter.
For example, your app.config includes a valid connection string with the name MyConnString. In this case, fill the following field in the Edit Connection String window:
Name: MyConnString

Post Reply