Page 1 of 1

The underlying provider failed on Open exception

Posted: Sun 10 May 2020 06:27
by Thenrich
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 )

Re: The underlying provider failed on Open exception

Posted: Tue 12 May 2020 16:46
by Shalex
There should be an inner exception. Specify its message and full stack trace.

Re: The underlying provider failed on Open exception

Posted: Tue 12 May 2020 18:50
by Thenrich
This is a text message in the Linq interactive window. How do you view the inner exception in there?

Re: The underlying provider failed on Open exception

Posted: Wed 13 May 2020 10:51
by Shalex
The inner exception should be in the same window just after the error you have specified.

Re: The underlying provider failed on Open exception

Posted: Wed 13 May 2020 20:42
by Shalex
Additional question: is the Target framework of your project .NET Framework or .NET Core?

Re: The underlying provider failed on Open exception

Posted: Wed 13 May 2020 22:03
by Thenrich
.NET Framework

Re: The underlying provider failed on Open exception

Posted: Thu 14 May 2020 02:47
by Thenrich
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?

Re: The underlying provider failed on Open exception

Posted: Fri 22 May 2020 16:26
by Shalex
Could you please send us a small test project so that we can reproduce the issue in our environment?

Re: The underlying provider failed on Open exception

Posted: Fri 22 May 2020 16:30
by Thenrich
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.

Re: The underlying provider failed on Open exception

Posted: Mon 25 May 2020 18:12
by Shalex
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