How to connect the MVC4 template to MySQL
-
- Posts: 3
- Joined: Sun 02 Sep 2012 16:20
How to connect the MVC4 template to MySQL
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
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
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:
This issue was discussed on the web.
http://social.msdn.microsoft.com/Forums ... d59cd65f32:
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)...
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
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.
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.
-
- Posts: 3
- Joined: Sun 02 Sep 2012 16:20
Re: How to connect the MVC4 template to MySQL
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.
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.
-
- Posts: 1
- Joined: Thu 15 Nov 2012 15:56
- Location: Naperville, IL
- Contact:
Re: How to connect the MVC4 template to MySQL
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
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
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
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
Awesome. Thank you.
Re: How to connect the MVC4 template to MySQL
Is there any update on SimpleMembership support in dotConnect?
Even any beta code that's available at this point would be great.
Even any beta code that's available at this point would be great.
Re: How to connect the MVC4 template to MySQL
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
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.
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
When waiting any example about this? In the release documentation (and examples) does not even mention ....