How to fix the unrecognized Attribute 'name' error in Webconfig?

Asked

Viewed 2,258 times

6

I am developing a web project in VS 2012, this application connects with a Mysql database developed in Mysqlworkbench 60 CE with Mysql server 5.6, I have referenced in the project the Entityframework version 6.1, Mysql.ConnectorNET.Data 6.8.3.2, mysqlconnector.Net. Entity 6.8.3.2,mysql. data, mysql.data.entitie, myslq.web all in version 6.8.3.

When I run my project a test class that performs data entry in the capture database and returns me the following error:

Unrecognized 'name' attribute. (C: Desktop Users Simulationvalues Web interface.config line 17)

I believe the error is in the webconfig below:

<?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>
    <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>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.data>
    <DbProviderFactories>
      <remove name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
  <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="bancotccEntities" connectionString="metadata=res://*/bancotcc.csdl|res://*/bancotcc.ssdl|res://*/bancotcc.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;user id=root;password=tcc2012;persistsecurityinfo=True;database=bancotcc&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

1 answer

5


It’s like this:

<DbProviderFactories>      
      <remove name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>

causes this error:

inserir a descrição da imagem aqui

Leave it at that:

<DbProviderFactories>      
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>

That is to say, withdraw name="MySQL Data Provider".

And the result will come out normally

inserir a descrição da imagem aqui

the attribute "name" does not exist.


Other factors that may influence

Change your Web.Config thus:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <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>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
  <!--<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="bancotccEntities" connectionString="metadata=res://*/bancotcc.csdl|res://*/bancotcc.ssdl|res://*/bancotcc.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;user id=root;password=tcc2012;persistsecurityinfo=True;database=bancotcc&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

And decorate your class you inherit from DbContext

[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
public partial class genericdbEntities : DbContext

In this case the class you inherit has the name of genericdbEntities

  • 2

    @Sunstreaker kkkk cool ... !!!

  • 1

    Hello, thanks for replying Harry Potter, I did what you suggested but I ended up in another error see below: bancotcc.ssdl(2,2) : error 0152: No Entity Framework Provider found for the ADO.NET Provider with invariant name 'Mysql.Data.Mysqlclient'. Make sure the Provider is Registered in the 'entityFramework' Section of the application config file. See http://go.microsoft.com/fwlink/? Linkid=260882 for more information

  • <system.data> <Dbproviderfactories> <remove name="Mysql Data Provider" invariant="Mysql.Data.Mysqlclient" /> <add name="Mysql Data Provider" invariant="Mysql.Data.Mysqlclient" Description=". Net Framework Data Provider for Mysql" type="Mysql.Data.Mysqlclient.Mysqlclientfactory, Mysql.Data, Version=6.8.3.0, Culture=neutral, Publickeytoken=c5687fc88969c44d" /> </Dbproviderfactories>

  • HI, thanks for the help and patience, but there was a </system.data> in the above section

  • Not without the remove it day that already exists the value for Data.MySqlClient.Mysqlclientfactory,

  • No Entity Framework Provider found for the ADO.NET Provider with invariant name 'Mysql.Data.Mysqlclient'. Make sure the Provider is Registered in the 'entityFramework' Section of the application config file. See http://go.microsoft.com/fwlink/? Linkid=260882 for more information

  • 1

    I’m sorry, but I’m new to the site

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.