Utilizzare EF6 con Mysql in Visual Studio 2017

Ritengo doveroso condivide la corretta procedura di configurazione di Visual Studio 2017 per permettere il funzionamento di Entity Framework 6 con Mysql (fonte https://stackoverflow.com/questions/28241500/cant-create-entity-data-model-using-mysql-and-ef6

  1. Install "MySQL for Visual Studio" v2.0.5 CTP (MySQL for Visual Studio). Note: Install MySQL for Visual Studio before Connector/NET.

  2. Install "Connector/NET" v6.9.10 (Connector/Net) Note: I tried using Connector/NET v6.8, v6.10 and v8 first, but none of them worked with Visual Studio 2017.

  3. Create new Visual Studio Professional 2017 project.

  4. Download and Install "EntityFramework" v6.2.0 through NuGet, by going to Project Tab/Manage NuGet Packages/Browse -> Entity Framework.

  5. Add references to C:\Program Files (x86)\MySQL\Connector.NET 6.9.10\Assemblies\v4.5\MySql.Data.dll and C:\Program Files (x86)\MySQL\Connector.NET 6.9.10\Assemblies\v4.5\MySql.Data.Entity.EF6.dll; by Right Clicking over References inside Solution Explorer and selecting Add Reference/Browse ->Browse button.

  6. Add MySQL EF6 provider info inside App.config under entity framework providers as follow:

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

     

  7. Rebuild project by going to Build tab/Rebuild ProjectName.
 
Comments are closed