0
votes

I try to connect my entity framework in MySQL database but when i connect this error happen

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.

This is my appConfig for my class library whit entity

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<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" />
</configSections>
<connectionStrings>
<add name="portallentesContext" connectionString="server=******;User Id=******;password=*********;Persist Security Info=True;database=portallentes"
  providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<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.6.4.0" />
</DbProviderFactories>
</system.data>

<entityFramework>
<providers>
  <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.4.0" >
  </provider>
</providers>
</entityFramework>
</configuration>
2
Did you install the MySQL Connector for .NET?Andrew
yes, i install mySQL ConnectorGuilherme Baldini
In the Package Manager Console, try running this command Install-Package EntityFramework -PreAndrew
I already did that tooGuilherme Baldini
What version of Entity Framework do you have?Andrew

2 Answers

0
votes

copy MySql.Data.Entity.EF5.dll with MySql.Data.Entity.EF6.dll together to the bin directory.

0
votes

Take a look at my answer here: https://stackoverflow.com/a/42588773/3652378.

Make sure you have MySql.Data.dllreferenced in the calling assembly (not only in the class library project, but also in the web application / wcf application which calls the class library).