Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
203 views
in Technique[技术] by (71.8m points)

c# - error: This operation would create an incorrectly structured document

I keep trying to install the entity framework 6 and it always rolls back with the error of

error: This operation would create an incorrectly structured document.

I've uninstalled all the references to every dll mentioned at this location. http://entityframework.codeplex.com/wikipage?title=Updating%20Applications%20to%20use%20EF6

The crazy thing is that i can create a new project, create a webAPI program, and attempt to add Entity Framework 6 and I get the same error, even after removing all references to System.Data.Entity.dll I'm already a few days into this, and needing serious help.

what can i do to get Entity Framework 6 to install?

Note: It will install just find to a class library just not a WebApi or MVC application.


If it helps here is some more detailed error info.

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same problem. It turned out that I was adding EF to one of my really old projects and web.config had this namespace defined for <configuration /> element:

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

Removing that namespace declaration (xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0") helped and solved this issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...