Monday 6 November 2017

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

This issue is Completely related to EntityFramework and this issue arises whenever you have installed EntityFramework in one project at that same time section is added in your web.config or app.config file like this,

Web.Config or app.config:-
------------------------
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
</configuration>

But later when you update the EntityFramework some times the Version will not Update in Web.Config  or app.config and while running and Using EntityFramework in Program it will Show you the Error like this "The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception".

To Resolve this Error,First Check what is the Current Version of EntityFramework in your References. Whatever the Version is Present in References Update the Same Version in Web.config or app.config.

Example:-
---------
Let's Say i had previously 5.0.0.0 and now i Updated to 6.0.0.0 So we need to Change the same thing in Web.config or app.config.
Web.Config or app.config:-
------------------------
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
</configuration>

0 comments:

Post a Comment