Connection Entity Framework with Mysql

2

I have done the procedures pointed out in these questions:

Entity Framework - Bank Compatibility

MySQL Connection Error asp.net MVC

I installed MySQL.Data.Entities.

My web.config looks like this:

  <connectionStrings>
    <add name="BancoDados" connectionString="Server=xxx;
         Database=xxx;
         Uid=xxx;
         Pwd=xxx;"
         providerName="System.Data.EntityClient"/>
  </connectionStrings>

<entityFramework>
    <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
    <providers>
        <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
    </providers>
</entityFramework>

However, running Add-Migration triggers the following error:

  

Keyword not supported: 'server'.

I tried to change the providerName to MySql.Data.MySqlClient , triggered the following error:

  

The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is   either not registered in the machine or application config file, or   could not be loaded. See the inner exception for details.

When installing the .Net Connector error:

  

System.NullReferenceException: Object reference not set to an instance   of an object. at   MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken (DbConnection   connection at   System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken (DbConnection   connection at   System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked (DbProviderServices   providerServices, DbConnection connection) at   System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.

asked by anonymous 07.11.2014 / 02:54

1 answer

3

Synthesizing what was put into comment:

1. Installing the MySQL .NET Connector

  

link

2. Configure the web.config file as follows:

<connectionStrings>
    <add name="BancoDados" providerName="MySql.Data.MySqlClient" connectionString="Data Source=xxxx; port=3306; Initial Catalog=bancoMySQL; uid=usuarioMySQL; pwd=qwe123qwe;" />
</connectionStrings>

<entityFramework>
    <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
    <providers>
        <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
    </providers>
</entityFramework>
    
12.11.2014 / 21:39