30 July 2013

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

Have you experienced this when you update the database (Code First) using the Package Manager?

I have a simple solution.

I just add the below script in web.config

<configSections>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
 </configSections>

and I made sure that the below script is present

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
 </entityFramework>


And everything went fine.

3 comments: