Friday, April 15, 2016

The Type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.

Cause
I received this error while working with Entity Framework 6.1 with C#.NET (4.5.2), I was trying to use 'Code First' approach. As I try to run my code I got this error at run time.
Actually in App.config file, I wrote my connection string section, immediate after "configuration" section. that was causing this issue.

Solution:
After long finding I found that issue is very small. To resolve this I re-arrange section in following order and it works for me

configuration
configSections
connectionStrings
startup
entityFramework
configuration

It's resolved the issues, for me.