Diagnosing the exception: System.Data.entity.Internal.appConfig threw an Exception

| By Webner

‘System.Data.entity.Internal.appConfig’ exception generally arises from your configuration file like web.config file due to some conflicting statements. I faced this error during login process:
During debugging I found that this error was thrown to me at the step of entity framework connection context initialization. I tried some suggested solutions. Some of them suggested the entity framework version issue and some provider duplicate issues. I changed the entity framework version, reinstalled Entity framework dlls from nuget and tried to change the target framework also. I tried to check provider issue. But it didn’t work for me.

The best way to diagnose this error is to view the innerException from exception where you can find the exact error. You can write in the exception handling code to print the error using the statement : System.Diagnostics.Debug.WriteLine(ex.InnerException) in the output debug window.

In the screenshot Below I have shown the exception object instance while debugging the code to view the InnerException:
In my case , it gave me the innerException that “default connection has been already added.” . In my case there were two duplicate default connection strings for entity framework connection written in the web.config file that threw me this exception.
For quickly finding the error, you can further expand to view this innerException to trace the exact line where the error was raised and to view some more details regarding this exception:

Leave a Reply

Your email address will not be published. Required fields are marked *