Error MySQL connection to ASP.NET MVC

4

I'm trying to work with a MySQL database in my application. However, I'm getting the following error:

  

Keyword not supported: 'data source'.

I've done all the related procedures in this question But briefly, I performed this installation on my NuGet

PM> Install-Package MySQL.Data.Entities

Web.config

  <connectionStrings>
    <clear />
    <add name="BancoDados" connectionString="Data Source=mysql01.hospedagemdesites.ws;
         Initial Catalog=catalog;
         User ID=userid;
         Password=password;"
         providerName="System.Data.EntityClient" />
  </connectionStrings>

App.config (EF Repository)

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

Context

[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
public class Contexto : DbContext
{
    public Contexto()
        : base("BancoDados")
    {
    }
    public DbSet<item> item { get; set; }
}
    
asked by anonymous 25.08.2014 / 17:20

2 answers

3

Data Source is for SQL Server. Change to:

  <connectionStrings>
    <clear />
    <add name="BancoDados" connectionString="Server=mysql01.hospedagemdesites.ws;
         Database=catalog;
         Uid=userid;
         Pwd=password;"
         providerName="MySql.Data.MySqlClient" />
  </connectionStrings>
    
25.08.2014 / 17:25
1

Put like this:

A ConnectionString Direct in the Constructor

[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
public class Contexto : DbContext
{
    public Contexto()
        : base("Server=mysql01.hospedagemdesites.ws;Database=catalog;Uid=userid;Pwd=password;")
    {
    }
    public DbSet<item> item { get; set; }
}
    
25.08.2014 / 17:36