locked
Error to create a View - This operation would create an incorrectly structured document RRS feed

  • Question

  • User-1870462563 posted

    Hello.

    I have the error below when I was try to create a new view in a existing project.

    This operation would create an incorrectly structured document

    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)

    The system does not have in the Web.config the line xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"

    After to try to create the view and saw the error, the referente to the Entity Framework desapear from the project. This is very strange.

    Someone has any ideia how to solve this?

    Thanks a lot! :)

    Monday, January 28, 2019 3:24 PM

All replies

  • User753101303 posted

    Hi,

    And your project is targeting which .NET version ? I don't have this namespace in my files (using 4.5 and later).

    Try perhaps https://docs.microsoft.com/en-us/ef/ef6/fundamentals/configuring/config-file to see what is expected for EF in your config file or maybe your weB.config file is currently malformed ???

    Monday, January 28, 2019 3:48 PM
  • User-1870462563 posted

    Hello PatriceSc.

    The version is .NET Framework 4.6.1

    The configurations in the web.config . I guess it is correct.

    <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" />
      <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="mssqllocaldb" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>

    Monday, January 28, 2019 3:55 PM
  • User1520731567 posted

    Hi JPSarno,

    When Entity Framework is upgraded, the app.config or web.config files will get stuff written into them. I suspect that might be the problem. Take a look at your app.config or web.config files. Maybe the EF upgrade is having trouble writing to them without making an invalid xml document.

    The solution that most people support is change the code below in web.config:

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

    to:

    <configuration>
    

    More details,you could refer to this link:

    https://stackoverflow.com/questions/19964620/error-this-operation-would-create-an-incorrectly-structured-document

    Best Regards.

    Yuki Tao

    Tuesday, January 29, 2019 6:16 AM