I’ve been googling all day to find out how to use the ASP.NET Login Controls with MySQL. And finaly I did it. I’m sharing this knowledge here.
Firstly I’ve installed Mysql.Data 5.2.2 (version 5.2.3 doesn’t auto generate schema). You can download it from here.
Add connection string in your web.config file for the database connection:
<connectionStrings>
<remove name="LocalMySqlServer"/>
<add name="LocalMySqlServer" connectionString="server=localhost; user id=root; password=pwd; persist security info=true; database=your_database;" providerName="MySql.Data.MySqlClient"/>
</ connectionStrings>
I have copied dll’s from MySql Program Files folder Mysql.Data and Mysql.Web into my application’s Bin folder and refreshed the Solution Explorer from Visual Studio.
Then edited my machine.config file and added autogenerateschema=”true” attribute at this line:
<membership>
<providers>
<add name="MySQLMembershipProvider" autogenerateschema="true" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=5.2.2.0, ... />
</providers>
</membership>
Finaly opened my ASP.Net Site Configuration (With the web site project loaded in Visual Web Developer, select Website › ASP.NET Configuration). Selected MySQLMembershipProvider from Membership Provide’s list and MySQLRoleProvider from Role Provider at Provider Tab. You can also do a test if the connection is ok.
I had these errors during the learning process :
There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
The following message may help in diagnosing the problem: Unable to initialize provider. Missing or incorrect schema. (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config line 145)
You could also see these pages. They got really helpfull to me:





I just recently worked through this process, too, and have also written an article on the steps I went through to set it up. That can be found here:
http://www.marvinpalmer.com/MarvinPalmer/post/Implement-NET-Membership-and-Roles-using-MySql-Connector-523-on-GoDaddy.aspx
I realise this is an old article now but I felt I must say thank you.
Have tried so many ‘solutions’ over the last few days with nothing working, tried this and finally got it working.
Thank you so very much.
You’re welcome…
Thanks so much for the article – cut a lot of work out
I’m using connector 5.2.5.0 which does appear to autogenerate OK – the only bit that threw me at first was I kept getting errors when trying to view website administration
Turns out you need to specify the defaultProvider in the web or machine config file for it to really work with VS2005
Just add ‘defaultProvider=”MySQLMembershipProvider”‘ to the membership tag and ‘defaultProvider=”MySQLRoleProvider”‘ to the roleManager tag and all is groovy
I also found it helped if I removed all reference to a previous MSSQL database I was using as this seemed to confuse things
Thanks again Simon
WEB.Config içerisine eklenecek kodlar aşağıda, Önemli Satır Mevcut providerları temizleyip aynı isimde provider eklenince porblem oluşturmuyor.