Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,
I am trying to make a project work by following this template
(https://dev.to/skipperhoa/login-and-register-using-asp-net-mvc-5-3i0g).
Locally it works well with an .mdf sql server database in the App_Data folder.
However, I would like to make it work on a Mysql server at a supplier.
But I do not know how !

I have installed the following Mysql files in the NuGet Package Manager:
MySql.Data, MySql.Data.Entity, MySql.Data.EntityFramework and MySqlConnector

I'm having trouble with the DB_Entities.cs file and HomeController.cs !

I modified the Web.config file but it does not work.
Can someone help me please?
Thank you

What I have tried:

Here is the web.config file:
C#
<connectionStrings>
   
    <add name="Connex_Bdd_MVC_Photo" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=3306;database=Mysite;uid=Bdd_MVC;password=myMdp />

  </connectionStrings>

  <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.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.22.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
    
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.22.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    
    </DbProviderFactories>
  </system.data>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900