配置系统无法初始化

问题描述 投票:0回答:1

我正在尝试从Package Manager控制台为Visual Studio 2013中的项目启用Code First迁移。 (上下文:我正在尝试从本教程(https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/preparing-databases)了解Web部署)

我输入:

PM>启用的迁移

并获得以下内容:

> Checking if the context targets an existing database...
> System.TypeInitializationException: The type initializer for
> 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an
> exception. ---> System.TypeInitializationException: The type
> initializer for 'System.Data.Entity.Internal.AppConfig' threw an
> exception. ---> System.Configuration.ConfigurationErrorsException:
> Configuration system failed to initialize --->
> System.Configuration.ConfigurationErrorsException: Unrecognized
> configuration section compilation. The type initializer for
> 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an
> exception.

我已经尝试过其他Stack Overflow帖子所建议的内容(以及ASP.NET论坛)但没有任何效果。其他帖子表明Web.config文件可能有问题,但我所做的任何更改都没有修复错误。

这是我的Web.config文件的开头:

<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
    </sectionGroup>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
.net visual-studio-2013 web-config
1个回答
0
投票

我将此代码段添加到我的Web.config文件中,但将其放在错误的位置:

<compilation debug="true" targetFramework="4.0">
        <assemblies>
          <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        </assemblies>
</compilation>

它应该是system.web的子代,而不是位置和运行时之间的子代。

© www.soinside.com 2019 - 2024. All rights reserved.