Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AccountController using MySQL in ASP.NET MVC

Creating a default ASP.NET MVC project in Visual Studio sets up a basic project where you can register a user. How would I go on changing this to use a MySQL server instead of SQLServer ?

like image 362
nos Avatar asked Jul 26 '09 18:07

nos


1 Answers

Got it working now.

  • Install the latest Connector/NET (v 6.0.4.0 currently)
  • Replace the default connection string in web.config with something like:

    <add name="ApplicationServices" connectionString="server=192.168.1.30;user id=thsuser;Password=thepass;database=thedatabase" providerName="MySql.Data.MySqlClient"/>

  • Under the section in web.config add the following (for the 6.0.4.0 mysql connector atleast), add

    <add autogenerateschema="true" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />

  • Run the project, go back into Visual Studio and click the ASP.NET Configuration button above the solution explorer.

    Navigate to "Provider Configuration"->"Select a different provider for each feature " and select the "MySQLMembershipProvider"

Works atleast for registering and logging in from a mysql database, the MySQLMembershipProvider will autogenerate the needed tables.

like image 188
nos Avatar answered Nov 06 '22 09:11

nos