MySQL and .Net 4 Membership...

Soldato
Joined
28 Aug 2006
Posts
3,003
Well MS certainly didn't make this a simple task.

Just trying to get my head around the many different google answers.

Has anyone had to go down this route?
 
Soldato
OP
Joined
28 Aug 2006
Posts
3,003
Any reason you're not using SQL Express?

Not sure my hosting supports that. They have a MS SQL server, with 1 free DB. But additional DBs cost.

I'd like to go down the MySQL route as thats not limited.

I'm surprised that Membership has specific MS SQL stuff in it. Surely they should have decoupled it from the DAL.

I tried the earlier example, for .net 4 and MVC 4, but it broke things. I'm guessing I need a few extra classes for Membership and Roles.

They don't like to make things simple :S
 
Soldato
OP
Joined
28 Aug 2006
Posts
3,003
I don't think its as easy as that. From my googling, it sounds like the default membership classes have some specific MS SQL code. So im guessing i'd need to implement some replacement classes to generalise the SQL specific methods.
 
Soldato
OP
Joined
28 Aug 2006
Posts
3,003
It breaks on UsersContextobject, which it says can't be found.

UsersContext is a class derived from DbContext which is defined in the Models\AccountModel.cs file.

I'll keep plugging away at it, when time allows.
 
Soldato
OP
Joined
28 Aug 2006
Posts
3,003
Thanks, downloaded the zip you did and will give it another go during the week.

Thanks for everyones' input. Greatly appreciated.
 
Soldato
OP
Joined
28 Aug 2006
Posts
3,003
I just tried the guide I/Shad posted and it works fine.

  1. Install MySQL connector .NET
  2. Create a membership database in MySQL
  3. Update your connection string in web.config to point to your new DB
  4. Go to Project > ASP.NET configuration in Visual Studio and create a user under the security section
  5. Do all the account fixes from the guide
  6. Launch your project and login

Here's a working zip of love with it all done:
https://dl.dropbox.com/u/41110491/Web.Membership.MySQL.zip

Enjoy :).

I did exactly as said, and I still get the "UsersContext" error. So I compared my solution with your zip.

It seems that my default MVC4 solution adds Filters > InitializeSimpleMembershipAttribute.cs which is missing from your zip. So I have now removed his file and it compiles again.
 
Back
Top Bottom