Page 1 of 1

How to connect the MVC4 template to MySQL

Posted: Sun 02 Sep 2012 18:37
by stivoberlin
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

Re: How to connect the MVC4 template to MySQL

Posted: Thu 06 Sep 2012 11:07
by Shalex
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.

Re: How to connect the MVC4 template to MySQL

Posted: Thu 27 Sep 2012 11:11
by snielsson
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.

Re: How to connect the MVC4 template to MySQL

Posted: Thu 27 Sep 2012 12:13
by stivoberlin
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.

Re: How to connect the MVC4 template to MySQL

Posted: Thu 15 Nov 2012 16:02
by mattjcowan
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

Re: How to connect the MVC4 template to MySQL

Posted: Sun 02 Dec 2012 13:01
by kasperhj
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.

Re: How to connect the MVC4 template to MySQL

Posted: Fri 07 Dec 2012 08:29
by Shalex
We are going to add the SimpleMembership support in dotConnect for MySQL in the nearest future. We will post here when it is implemented.

Re: How to connect the MVC4 template to MySQL

Posted: Sun 09 Dec 2012 12:04
by kasperhj
Awesome. Thank you.

Re: How to connect the MVC4 template to MySQL

Posted: Mon 28 Jan 2013 19:33
by nickh
Is there any update on SimpleMembership support in dotConnect?

Even any beta code that's available at this point would be great.

Re: How to connect the MVC4 template to MySQL

Posted: Tue 29 Jan 2013 16:08
by Shalex
We are planning to implement the SimpleMembership support in next public build of dotConnect for MySQL.

Re: How to connect the MVC4 template to MySQL

Posted: Thu 28 Feb 2013 17:59
by Shalex
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.

Re: How to connect the MVC4 template to MySQL

Posted: Thu 28 Feb 2013 22:14
by DrNix
When waiting any example about this? In the release documentation (and examples) does not even mention ....

Re: How to connect the MVC4 template to MySQL

Posted: Fri 01 Mar 2013 08:03
by Shalex