Home:ALL Converter>Setup Entity Framework 6 with Mysql - Code first

Setup Entity Framework 6 with Mysql - Code first

Ask Time:2017-03-28T23:33:50         Author:Gonzalo Fernandez

Json Formatter

I am trying to setup a existing project to use Entity Framework. I have never used it before and want to learn it on a personal project.

I have a solution with many projects, all related. Login is where I wanna do querys. Model is where the model is. Main is where the program starts.

I have installed EntityFramework onto MySolution.Model.

This is the app.config for Model:

<connectionStrings>
    <add name="ALDatabaseContext" providerName="MySql.Data.MySqlClient"
        connectionString="server=localhost;port=3306;database=aldatabase;uid=root;password=root"/>
</connectionStrings>
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
    <provider invariantName="MySql.Data.MySqlClient"
      type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"/>
     <provider invariantName="System.Data.SqlClient"
      type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>

My context is very simple

public class ALDatabaseContext : DbContext
{
    public virtual DbSet<User> Users { get; set; }
}

But when I call context from Login I get an exception:

Additional information: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file.

What I am missing?

Author:Gonzalo Fernandez,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43073834/setup-entity-framework-6-with-mysql-code-first
yy