Entity Framework type initializer app config RRS feed

  • General discussion

  • Update:

    There is a bug in .Net 4.0 Client profile, it requires a hotfix to read config files that EF uses to read the connectionstrings.

    I'm creating a WPF application that uses Entity Framework 6.0 for .Net 4.0 Client Profile

    In development everything works fine, even without visual studio.

    Every other PC (Xp and Win7) gets these exceptions when i start the application (and create the EF6 context).

    Exception type      : System.TypeInitializationException
    Exception message   : The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.

    Exception type      : System.Configuration.ConfigurationErrorsException
    Exception message   : An error occurred creating the configuration section handler for entityFramework: Request failed.(path\to\configfile.Config line 10)

    Exception type      : System.Security.SecurityException
    Exception message   : Request failed.

    The configuration file:

    <?xml version="1.0" encoding="utf-8"?>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      <!-- For more information on Entity Framework configuration, visit --></configSections>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        <add name="TotalisDatabase" connectionString="Data Source=TOTALSERVER\SQLEXPRESS;Initial Catalog=Totalis;User ID=user;Password=password" providerName="System.Data.SqlClient" />

    The exception gets thrown at this line:

    context = new TotalisContext();
    (I dispose the context when the application stops)

    • Edited by Zef Ubachs Friday, December 13, 2013 4:34 PM
    • Moved by CoolDadTx Friday, December 13, 2013 4:46 PM EF related
    • Changed type Fred BaoModerator Monday, December 30, 2013 7:24 AM
    Friday, December 13, 2013 11:03 AM

All replies

  • Hello Zef Ubachs,

    Thanks for your test and feedback. For this issue, I have submit this feedback to the MS team:

    As soon as they have any result, I will tell you.

    Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 16, 2013 5:32 AM