从Nuget安装Entity Framework 6.0.1时出错(此操作会创建一个结构不正确的文档。)

时间:2014-04-23 18:24:28

标签: entity-framework

在我的ASP.NET MVC 5中,我需要使用Entity Framework。我已经尝试通过Nuget包安装最新的Entity框架,但是我在下面收到以下错误。我已经粘贴了完整的nuget堆栈错误。我尝试过几个例子,例如卸载/安装EF,手动添加EF引用等。但是到目前为止还没有工作,我已经失去了2天。

I have tried links similar to my problem here in this site and even that has not helped and hence starting new thread hoping that someone will help me here! 
Need help here...I am stuck.

Error stack:

Install-Package EntityFramework
Installing 'EntityFramework 6.1.0'.
You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkID=320539. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'EntityFramework 6.1.0'.
Adding 'EntityFramework 6.1.0' to EPP.
Successfully added 'EntityFramework 6.1.0' to EPP.
System.InvalidOperationException: This operation would create an incorrectly structured document.
   at System.Xml.Linq.XDocument.ValidateDocument(XNode previous, XmlNodeType allowBefore, XmlNodeType allowAfter)
   at System.Xml.Linq.XDocument.ValidateNode(XNode node, XNode previous)
   at System.Xml.Linq.XContainer.AddNodeSkipNotify(XNode n)
   at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
   at System.Xml.Linq.XContainer.Add(Object content)
   at System.Data.Entity.Migrations.Extensions.XContainerExtensions.GetOrCreateElement(XContainer container, String elementName, XAttribute[] attributes)
   at System.Data.Entity.ConnectionFactoryConfig.ConfigFileManipulator.AddOrUpdateConfigSection(XDocument config, Version entityFrameworkVersion)
   at System.Data.Entity.ConnectionFactoryConfig.InitializeEntityFrameworkCommand.<>c__DisplayClass3.<Execute>b__1(XDocument c)
   at System.Data.Entity.ConnectionFactoryConfig.ConfigFileProcessor.ProcessConfigFile(ProjectItem configItem, IEnumerable`1 manipulators)
   at System.Data.Entity.ConnectionFactoryConfig.InitializeEntityFrameworkCommand.<>c__DisplayClass3.<Execute>b__0(ProjectItem i)
   at System.Data.Entity.ConnectionFactoryConfig.ConfigFileFinder.FindConfigFiles(ProjectItems items, Action`1 action)
   at System.Data.Entity.ConnectionFactoryConfig.InitializeEntityFrameworkCommand.Execute()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Uninstalling 'EntityFramework 6.1.0'.
Successfully uninstalled 'EntityFramework 6.1.0'.
Install failed. Rolling back...`enter code here`
Install-Package : This operation would create an incorrectly structured document.
At line:1 char:16
+ Install-Package <<<<  EntityFramework
    + CategoryInfo          : NotSpecified: (:) [Install-Package], RuntimeException

1 个答案:

答案 0 :(得分:1)

升级Entity Framework后,app.config或web.config文件会将内容写入其中。检查您的web.config文件。来自here,错误是

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

在线路更改为

时修复
<configuration>