How to connect the MVC4 template to MySQL

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply

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

stivoberlin
Posts: 3
Joined: Sun 02 Sep 2012 16:20

How to connect the MVC4 template to MySQL

Post by 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/ ... mysql.html
but it seems, it doesn't work with the MVC4 template.

I would be very glad to find a solution :-)
Steve

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: How to connect the MVC4 template to MySQL

Post by 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 ... d59cd65f32:
MVC 4 uses the new and improved SimpleMembership extension to the ASP.NET membership framework:
http://blog.osbornm.com/archive/2010/07 ... pages.aspx
http://www.asp.net/web-pages/tutorials/ ... 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.

snielsson
Posts: 3
Joined: Thu 27 Sep 2012 10:47

Re: How to connect the MVC4 template to MySQL

Post by 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.

stivoberlin
Posts: 3
Joined: Sun 02 Sep 2012 16:20

Re: How to connect the MVC4 template to MySQL

Post by 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.

mattjcowan
Posts: 1
Joined: Thu 15 Nov 2012 15:56
Location: Naperville, IL
Contact:

Re: How to connect the MVC4 template to MySQL

Post by 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

kasperhj
Posts: 7
Joined: Thu 22 Nov 2012 14:05

Re: How to connect the MVC4 template to MySQL

Post by 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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: How to connect the MVC4 template to MySQL

Post by 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.

kasperhj
Posts: 7
Joined: Thu 22 Nov 2012 14:05

Re: How to connect the MVC4 template to MySQL

Post by kasperhj » Sun 09 Dec 2012 12:04

Awesome. Thank you.

nickh
Posts: 4
Joined: Wed 08 Feb 2012 07:52

Re: How to connect the MVC4 template to MySQL

Post by 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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: How to connect the MVC4 template to MySQL

Post by Shalex » Tue 29 Jan 2013 16:08

We are planning to implement the SimpleMembership support in next public build of dotConnect for MySQL.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: How to connect the MVC4 template to MySQL

Post by 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.

DrNix
Posts: 1
Joined: Thu 28 Feb 2013 21:59

Re: How to connect the MVC4 template to MySQL

Post by DrNix » Thu 28 Feb 2013 22:14

When waiting any example about this? In the release documentation (and examples) does not even mention ....

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: How to connect the MVC4 template to MySQL

Post by Shalex » Fri 01 Mar 2013 08:03


Post Reply