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

前端 未结 26 1162
臣服心动
臣服心动 2020-11-30 06:17

I\'m working with EF5 in a MVC 4 aspnet website. Locally, everything works just fine, but when I publish it to the IIS and try to enter, I get the error

26条回答
  •  半阙折子戏
    2020-11-30 06:45

    Old question but it just happened to me for different reasons mentioned in the other answers, so I thought I'd share my findings.

    In my case, the problem was how I defined my connection string entry in the app.config. I edited it directly in Notepad++ and I must have hit a shortcut, and minimized the entire string which I didn't spot, and started to get this error. This is how I was defined it:

    
    

    The second I changed the following parameters

    connectionstring to connectionString
    

    and

    providername to providerName
    

    Note: The problem was highlighted immediately In Visual Studio but clearly this isn't ideal if you're on a client site!

提交回复
热议问题