6

Estou desenvolvendo uma projeto web no VS 2012, esta aplicação se conecta com um banco MySQL desenvolvido no MySQLWorkbench 60 CE com o servidor MySQL 5.6, tenho referenciado no projeto o EntityFramework versão 6.1, MySql.ConnectorNET.Data 6.8.3.2, mysql.connectorNet. entity 6.8.3.2,mysql.data, mysql.data.entitie, myslq.web todos na versão 6.8.3.

Quando executo o meu projeto uma classe de teste que realiza a inserção de dados no banco captura e me devolve o seguinte erro:

Atributo 'name' não reconhecido. (C:\Users\Desktop\SimuladorBValores\Interface\web.config line 17)

Acredito que o erro esteja no webconfig que segue abaixo:

<?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 Resposta 1

5

Está assim:

<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>

provoca esse erro:

inserir a descrição da imagem aqui

Deixe assim:

<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>

Ou seja, retire name="MySQL Data Provider".

E vai sair o resultado normalmente

inserir a descrição da imagem aqui

o atributo "name" não existe.


Outros Fatores que podem influenciar

Mude seu Web.Config assim:

<?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>

E decore sua classe que herda do DbContext

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

No caso esse exemplo a classe que herda tem o nome de genericdbEntities

7
  • 2
    @Sunstreaker kkkk legal ... !!!
    – user6026
    Commented 28/05/2014 às 23:29
  • 1
    Ola, obrigado por responder Harry Potter, fiz o que você me sugeriu mas acabei em outro erro veja abaixo: 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 go.microsoft.com/fwlink/?LinkId=260882 for more information
    – user9090
    Commented 28/05/2014 às 23:42
  • <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>
    – user9090
    Commented 29/05/2014 às 0:38
  • OI, obrigado pela ajuda e paciência, mas não faltou um </system.data> no trecho acima
    – user9090
    Commented 29/05/2014 às 1:00
  • 1
    Desculpa mas sou novo no site entrei no bate papo as não consigo falar com vc
    – user9090
    Commented 29/05/2014 às 1:40

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .