.NET Simple Membership Provider for SqlServer, MySql, Access or Oracle

You can find the source code here

This SimpleMembershipProvider is written in C#.NET and tested against both SQL Server and MySQL. It is assumed that this will work against other relational databases also.


.NET Simple Membership Provider was originally developed to work with SQL Server database only. The need arisen when we had to migrate our data source from SQL Server to MySQL. The simple membership provider that was initially written for SQL Server in one of our projects did not remain functional against MySQL.

This project is a slight modification of the original implementation of .NET Simple Membership Provider.

How do I get set up?

The Unco.SimpleMembershipProvider is extremely easy to setup. You can either add this project to your existing solution or add just a reference dll of this project to your project. Rest of the setup is similar to .NET Simple Membership Provider that is included in WebMatrix.Data namespace.

  • Follow these steps to setup Unco.MembershipProvider
  • Add a reference of Unco.MembershipProvider to your project.
  • In your web.config along with connection string add the membership provider within tag boundary as follows
<membership defaultProvider="SimpleMembershipProvider">
 <clear />
 <remove name="SimpleMembershipProvider" />
 <add name="SimpleMembershipProvider"
 type="Unco.MembershipProvider.SimpleMembershipProvider, Unco.MembershipProvider"
  • Add a connection string as follows:
 <add name="DefaultConnection"
 connectionString="server=;user id=mysql;password=mysqlpwd;database=DatabaseName;persistsecurityinfo=True"
  • Replace WebMatrix.WebData namespace with Unco.MembershipProvider in your code file where you will initialize the SimpleMembershipProvider. The code you previously used to work with Sql Server database may look like this
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
  • replace this code with the following:
WebSecurity.InitializeDatabaseConnection("DefaultConnection", DatabaseType.MySql, "UserProfile", "UserId", "UserName", autoCreateTables: true);

where DatabaseType is an enum

public enum DatabaseType

To understand how this enum works you will have to investigate the code a bit. In short this is to identify the database and add relevant attributes to the SQL Queries.

You should now be able to use SimpleMembershipProvider with MySql.

Note: Please let me know if you find any issues with this implementation.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s