How to connect the MVC4 template to MySQL

In your websites :

i use the devart membershipprovider
2
67%
i developed my own simple membershipprovider
1
33%
i use the new webmatrix thing (btw what's that ?)
0
No votes
i use my own authentification methods (own classes)
0
No votes
 
Total votes : 3

How to connect the MVC4 template to MySQL

Postby stivoberlin » Sun 02 Sep 2012 18:37

Hello, does someone know how to link an ASP.NET MVC4 site to MySql (Membership, roles, profiles, sessions, etc...)

Here is the starting point :
1) Start VS2012
2) New project ... "ASP.NET MVC4 Web Application"
3) Internet Application (Razor)
Now, it works... We can register, using SQL server (ok, I suppose the sessions are still 'in proc', isn't it ?)

How can we now change this project to use MySql ?
How do we do it using the Devart libraries ?
I have done it with MVC3 : http://stivodotnet.blogspot.ch/2012/09/link-your-aspnet-mvc3-to-mysql.html
but it seems, it doesn't work with the MVC4 template.

I would be very glad to find a solution :-)
Steve
stivoberlin
 
Posts: 3
Joined: Sun 02 Sep 2012 16:20

Re: How to connect the MVC4 template to MySQL

Postby Shalex » Thu 06 Sep 2012 11:07

Which error are you getting with MVC4 (.NET4.5) and dotConnect for MySQL in your environment?
We have received the following error in our test after registering Devart's ASP.NET providers in web.config:
Code: Select all
InvalidOperationException: To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider".]
   WebMatrix.WebData.WebSecurity.VerifyProvider() +106
   WebMatrix.WebData.WebSecurity.Login(String userName, String password, Boolean persistCookie) +46
   MvcApplication1.Controllers.AccountController.Login(LoginModel model, String returnUrl)...

This issue was discussed on the web.
http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/d352bb1b-577c-42b7-8872-5ed59cd65f32:
MVC 4 uses the new and improved SimpleMembership extension to the ASP.NET membership framework:
http://blog.osbornm.com/archive/2010/07/21/using-simplemembership-with-asp.net-webpages.aspx
http://www.asp.net/web-pages/tutorials/security/16-adding-security-and-membership

Simplemembership extends the asp.net membership system but has a different schema as compared to asp.net providers

MVC3 used the asp.net sql membership providers

which authentication you want, Webmatrix or ASP.NET membership provider, if you want Webmatrix, you need to remove ASP.NET membership provider, if you want to use ASP.NET, give up webmatrix class and methods.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: How to connect the MVC4 template to MySQL

Postby snielsson » Thu 27 Sep 2012 11:11

so what does this mean?

If Dev arts own team also get errors then what? Is it not possible to get the default asp.net mvc internet application to work with dotConnect ? If it is, please provide some example or tutorial. Right now I am evaluating whether to use SQLServer or Postgresql.
snielsson
 
Posts: 3
Joined: Thu 27 Sep 2012 10:47

Re: How to connect the MVC4 template to MySQL

Postby stivoberlin » Thu 27 Sep 2012 12:13

For now, to link authentication to MySQL, that's what I do :

1) Create a class MySimpleMemberShip that inherits from WebMatrix.WebData.ExtendedMembershipProvider
Write myself the code (only the ones needed).
2) Add this in the web.config (system.web section) :
<membership defaultProvider="SbMembershipProvider">
<providers>
<clear/>
<add
name="SbMembershipProvider"
type="Sandbox4.SbMembershipProvider"
connectionStringName="SandboxContext"
applicationName="Sandbox4"
enablePasswordRetrieval="false"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
passwordFormat="Clear"
/>
</providers>
</membership>


seems to work for now... but I m just at the beginning.
stivoberlin
 
Posts: 3
Joined: Sun 02 Sep 2012 16:20

Re: How to connect the MVC4 template to MySQL

Postby mattjcowan » Thu 15 Nov 2012 16:02

stivoberlin is correct, you need to override the ExtendedMembershipProvider...

I use DevArt this way to connect to MySql in MVC4 (I also use LLBLGen, which allows me to connect to Oracle, DB2, etc... as well). Sample implementation of a custom ExtendedMembershipProvider: SimpleMembershipProvider in MVC4 for MySql, Oracle, and more with LLBLGen
mattjcowan
 
Posts: 1
Joined: Thu 15 Nov 2012 15:56
Location: Naperville, IL

Re: How to connect the MVC4 template to MySQL

Postby kasperhj » Sun 02 Dec 2012 13:01

I am having the same problem. Why does this not work out of the box? I don't want to write a lot of code just to get this to work.
kasperhj
 
Posts: 7
Joined: Thu 22 Nov 2012 14:05

Re: How to connect the MVC4 template to MySQL

Postby Shalex » Fri 07 Dec 2012 08:29

We are going to add the SimpleMembership support in dotConnect for MySQL in the nearest future. We will post here when it is implemented.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: How to connect the MVC4 template to MySQL

Postby kasperhj » Sun 09 Dec 2012 12:04

Awesome. Thank you.
kasperhj
 
Posts: 7
Joined: Thu 22 Nov 2012 14:05

Re: How to connect the MVC4 template to MySQL

Postby nickh » Mon 28 Jan 2013 19:33

Is there any update on SimpleMembership support in dotConnect?

Even any beta code that's available at this point would be great.
nickh
 
Posts: 4
Joined: Wed 08 Feb 2012 07:52

Re: How to connect the MVC4 template to MySQL

Postby Shalex » Tue 29 Jan 2013 16:08

We are planning to implement the SimpleMembership support in next public build of dotConnect for MySQL.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: How to connect the MVC4 template to MySQL

Postby Shalex » Thu 28 Feb 2013 17:59

New version of dotConnect for MySQL 7.5 is released!
It can be downloaded from http://www.devart.com/dotconnect/mysql/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=2&t=26102.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: How to connect the MVC4 template to MySQL

Postby DrNix » Thu 28 Feb 2013 22:14

When waiting any example about this? In the release documentation (and examples) does not even mention ....
DrNix
 
Posts: 1
Joined: Thu 28 Feb 2013 21:59

Re: How to connect the MVC4 template to MySQL

Postby Shalex » Fri 01 Mar 2013 08:03

Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for MySQL