views:

643

answers:

2

I am not at all familiar with ASP.NET membership/roles. This is my first time using it, and my first time trying ASP.NET MVC. When I create my first project for MVC, it gives me a lovely template to create an account. I was excited to see that I did not have to do this manually. However, it failed because it cannot connect to SQL Server. I do not have SQL Server, I have MySQL. Is there any easy way I can get this system to use MySQL instead, or will I have to create my own authentication?

A: 

Click on the menu Project followed by ASP.NET Configuration.

That will create the sql database for you in the Data folder.

Use Visual Studio to look at the data.

Hope this helps.

Edit

I should add that you can then use Ctrl+Alt+S to see the Server Explorer which should then allow you to see your database with its tables and the data.

You shouldn't need SQL installed.

griegs
I got the tool to finally come up (it is slower than molasses), but I don't see any database. I went to security tab, and tried to select a data store. Then it gives me a list of providers, but only one is there (AspNetSqlProvider), but this gives me the same error (cannot connect to SQL server).
Josh Stodola
In visual studio can you now see the aspnetdb.mdf file? It should be in the App_Data folder. Ensure you are showing all files.
griegs
No. MDF = SQL Server. I do *not* have SQL Server.
Josh Stodola
You'll need to edit your web.config to use your provider then
griegs
+3  A: 

Got it figured out! Using version 6.2.2.0 of MySql Connector/Net, follow these steps...

  • Add reference to MySql.Web.dll
  • Change your <membership> in web.config to this:

    <membership defaultProvider="MySqlMembershipProvider">
      <providers>
        <clear/>
        <add name="MySqlMembershipProvider"
             type="MySql.Web.Security.MySQLMembershipProvider,
                   MySql.Web, Version=6.2.2.0, Culture=neutral,
                   PublicKeyToken=c5687fc88969c44d"
             autogenerateschema="true"
             connectionStringName="NAME_OF_YOUR_CONN_STRING"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             requiresUniqueEmail="false"
             passwordFormat="Hashed"
             maxInvalidPasswordAttempts="5"
             minRequiredPasswordLength="6"
             minRequiredNonalphanumericCharacters="0"
             passwordAttemptWindow="10"
             passwordStrengthRegularExpression=""
             applicationName="/"
         />
      </providers>
    </membership>
  • Run the Project | ASP.NET Configuration tool and click on the Security tab to test
  • Tested on ASP.NET 3.5, MySQL Server version 5.1, Windows XP 64-bit
Josh Stodola
Blogged: http://blog.josh420.com/archives/2010/01/aspnet-membership-profile-and-role-providers-for-mysql.aspx
Josh Stodola