Is it possible to use Simple Membership Provider with mysql(also using Entity Framework)
If yes, how to achieve it.
Any documentation/link is really appreciated
Thank in advance
I create MySqlSimpleMembershipProvider on GitHub and make sample projects.
https://github.com/xyz37/MySqlSimpleMembershipProvider
That's all.
Thank you for the answer to this question.
Click to sample screenshot : https://raw.github.com/xyz37/MySqlSimpleMembershipProvider/master/_ScreenShot/SimpleMembershipProviderTest.png
Check this brief article from Fabio Costa on how to use SimpleMembership and OAuth with mySQL and bigint or any database and datatype you want: http://fabiocosta.ca/2012/11/24/use-simplemembership-and-oauth-with-any-database-and-datatype/. It should solve your problem. Good luck.
I also did following changes to my code:
Added references to MySql.Data, MySql.Data.Entity and MySql.Web. Modified property 'Copy Local' to true on each reference.
Changed connectionstring and added DbProviderFactory in web.config to enable MySql connections.
Added roleManager and memberShip configuration in web.config.
web.config
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=localhost;Database=dbname;User ID=username;Password=password;" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<clear />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<system.web>
<roleManager enabled="true" defaultProvider="simple">
<providers>
<clear/>
<add name="simple" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData"/>
</providers>
</roleManager>
<membership defaultProvider="simple">
<providers>
<clear/>
<add name="simple" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData"/>
</providers>
</membership>
</system.web>
_AppStart.cshtml
@{
if (!WebSecurity.Initialized)
{
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
}
}
App_Start\FilterConfig.cs
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new InitializeSimpleMembershipAttribute());
}
}
Unfortunately, no.
SimpleMembershipProvider
is ultimately just a derived class of the good, old MembershipProvider
that we all love and hate.
It's there because people didn't like just how many abstract functions you'd have to override to get a custom MembershipProvider
working. So this is a very much dumbed-down implementation of MembershipProvider
. You'd have to go back re-override the implementations for these functions with SimpleMembershipProvider
.
I had the same question about modifying the DB design, had to go back to a custom MembershipProvider
class.
Also, taken from Microsoft employee/ASP.NET developer John Galloway's blog:
While SimpleMembership is not database agnostic, it works across the SQL Server family. It continues to support full SQL Server, but it also works with SQL Azure, SQL Server CE, SQL Server Express, and LocalDB. Everything's implemented as SQL calls rather than requiring stored procedures, views, agents, and change notifications.
Note that SimpleMembership still requires some flavor of SQL Server - it won't work with MySQL, NoSQL databases, etc. You can take a look at the code in WebMatrix.WebData.dll using a tool like ILSpy if you'd like to see why - there are places where SQL Server specific SQL statements are being executed, especially when creating and initializing tables. It seems like you might be able to work with another database if you created the tables separately, but I haven't tried it and it's not supported at this point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With