Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jayprajapati857/f52c68dfb8c2f27567ac6920285d8e6e to your computer and use it in GitHub Desktop.
Save jayprajapati857/f52c68dfb8c2f27567ac6920285d8e6e to your computer and use it in GitHub Desktop.
Installing MySQL 8.0 Server with EntityFramework in Visual Studio 2019

Installing MySQL 8.0 Server with EntityFramework in Visual Studio 2019

  • Install MySQL Server 8.0.16

  • Install Complete MySQL Connector.Net x86 8.0.16

  • Install this custom repacked VSIX MySQL Visual Studio

  • If after installing MySQL Visual Studio Plugin it shows warning that failed to execute comamnd devenv /updateconfiguration, then manually execute that command in Developer Command Prompt for Visual Studio 20xx with run as administrator.

  • Run this command Install-Package EntityFramework in Visual Studio Nuget package manager console

  • Manage Nuget Packages > Search Mysql > install Mysql.Data v8.0.16

  • Manage Nuget Packages > Search Mysql > install Mysql.Data.Entity v6.10.8

  • Manage Nuget Packages > Search Mysql.Data.EntityFramework > install Mysql.Data.EntityFramework v8.0.16

  • Comment the following kind of similar code from Web.config which is already added by the project

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
      </provider><provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.16.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
      </provider></providers>
</entityFramework>
  • Add this lines if its not automatically added after </runtime> tag in Web.config and rebuild solution
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <!--<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
      </provider>-->
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.16.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
      </provider>
    </providers>
  </entityFramework>
  • Comment <compilers> in Web.config as per below
  <system.codedom>
    <!--<compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>-->
  </system.codedom>
  • Even if doing all the above process some error occurs, then try uninstall nuget packages all the above added and UnInstall-Package EntityFramework uninstall visual studio plugin and connector net. Then rebuild fresh project, and add only Install-Package EntityFramework and then add references only Mysql.Data and Mysql.Data.EntityFramework for EF6 and then add the provider xml in web.config as mentioned above and remove the white space between the <provider> and </provider> tags, and rebuild project and finally try to add model.

  • This process is tested and working for .Net Framework 4.7.2 on Visual Studio 2019

Helpers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment