繁体   English   中英

元素'entityFramework'具有无效的子元素Entity Framework

[英]The element 'entityFramework' has invalid child element Entity Framework

我创建新的项目web asp.net mvc 4,当我去工具 - >库包管理器 - >管理nuget解决方案包。 并安装了实体框架。 在列表中安装警告显示后

警告:元素'entityFramework'具有无效的子元素'providers'。 预期可能元素列表:'上下文'。

我正在使用visual studio 2010,当访问web.config时,提供者标签上有一个下划线

</providers>

由于警告发生,我尽力寻找解决方案

如何解决警告:元素'entityFramework'具有无效的子元素'providers'。 预期可能元素列表:'contexts'


元素'entityFramework'具有无效的子元素'providers'。 预期可能元素列表:'contexts'

但失败的原因是这个错误以及如何应对。
web.config中

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<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" />
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <connectionStrings> 
  <add name="EmployeeContext"
       connectionString = "server=WALEED-PC\UOG; database=sample; Integrated Security=SSPI"
       providerName="System.Data.SqlClient"/>
  </connectionStrings>


  </configuration>

注意:执行此操作时,您必须关闭visual studio。完成所有过程后,您必须重新启动Visual Studio。

我也遇到了同样的问题。我通过复制两个文件来解决这个错误

(1)EntityFrameworkCatalog.xml文件(2)EntityFrameworkConfig_6_0_0.xsd

来自https://entityframework.codeplex.com/SourceControl/latest#src/EFTools/setup/EFToolsMsi/XmlSchemas/EntityFrameworkCatalog.xml

并将这些文件放入

C:\\ Program Files \\ Microsoft Visual Studio 10.0 \\ Xml \\ Schemas ”文件夹。

首先从上面的链接下载整个zip文件。 从中提取上面两个文件(xml,xsd)从下面的位置

src \\ EFTools \\ setup \\ EFToolsMsi \\ XmlSchemas

并复制到

C:\\ Program Files \\ Microsoft Visual Studio 10.0 \\ Xml \\ Schemas ”。

为什么因为日复一日的软件更新。因为这个原因我们必须使用更新的软件。

(要么)

您可以从“ http://www.microsoft.com/en-us/download/details.aspx?id=40762 ”安装适用于VS2012的EF6 Designer,它将更新验证配置文件的架构。

尝试删除提供商:

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM