我一直尝试安装 Entity Framework 6,并且总是回滚并出现以下错误:

error: This operation would create an incorrectly structured document.

我已经卸载了对此位置提到的每个dll的所有引用。 http://entityframework.codeplex.com/wikipage?title=Updating%20Applications%20to%20use%20EF6

疯狂的事情是,即使删除了对 System.Data.Entity.dll 的所有引用之后,我仍然可以创建一个新项目,创建一个webAPI程序,并尝试添加Entity Framework 6,但仍收到相同的错误。几天之后,需要认真的帮助。

我该怎么做才能安装Entity Framework 6?

注意:它只会安装到类库中,而不是WebApi或MVC应用程序。

如果有帮助,这里是一些更详细的错误信息。
PM> Install-Package EntityFramework -Version 6.0.0
Installing 'EntityFramework 6.0.0'.
Successfully installed 'EntityFramework 6.0.0'.
Adding 'EntityFramework 6.0.0' to AC.
Successfully added 'EntityFramework 6.0.0' to AC.
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.0.0'.
Successfully uninstalled 'EntityFramework 6.0.0'.
Install failed. Rolling back...
Install-Package : This operation would create an incorrectly structured document.
At line:1 char:16
+ Install-Package <<<<  EntityFramework -Version 6.0.0
    + CategoryInfo          : NotSpecified: (:) [Install-Package], RuntimeException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

最佳答案

Entity Framework 升级后,app.config或web.config文件将内容写入其中。我怀疑这可能是问题所在。查看您的app.config或web.config文件。也许EF升级无法在不创建无效xml文档的情况下写入它们。

关于c# - 错误: This operation would create an incorrectly structured document,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19964620/

10-17 01:48