Entity framework membership and role provider for MVC 3 and bootstrap

 

I recently started on a new implementation built on Microsoft MVC3. The problem I had was using the ASP.Net role and membership providers that ship out the box. They depend on a database created and configured using the ASP.Net forms auth tools , and sit in there own little database on sql server(or express or compact, whatever you are using). You can get around that by adding your data to the standard created database , but that’s kind of a hack(Not so cool Sad smile )and the fact is that I am using EF-Code first that provides me with some nice features for rapid development and proto typing of needed functionality thus the schema of the database will change quite a lot during the development process.

Digging a bit deeper into the out of the box forms auth , I found that there is also quite a lot of functionality that I would not use and thus the whole idea of using the out of the box forms authentication went out the window. Managing 2 databases (the forms auth one and then my own one) = not cool. Bloated code that has no use in the context = not cool.

So I decided to write my own providers to simplify my life for this project and for future projects with similar requirements (there will be plenty of them I’m sure.) I implemented 2 classes that inherit from the default providers to roll my own simpler authentication namely:

    public class CustomMembershipProvider : System.Web.Security.MembershipProvider   {}
    and
public class CustomRoleProvider : System.Web.Security.RoleProvider   {}
    NOTE: You have to then implement all the base methods from the abstract class inherited from and hook them up to the web.config and controllers, but its left out of this post as it is beyond the point that I am trying to make.
    I hooked it all up using Entity framework for storing the data in my own data structures, replacing the default providers with my own in the configs , and modified the default account controller in the MVC 3 template as provided and SHABANG !!!!!! ALL DONE.
    It all worked like a charm and provided a simplified mechanism with exactly what I needed.I then read up a bit about simple UI and designs for MVC (since I am not a design guru I generally try and see how other people do it Smile) and I came across an article of a gentleman by the name of Ryan Hayes. He has created a nifty little mvc3 template for VS2010 that contains an implementation of the open source EF-Code First Provider  membership provider that does pretty much exactly what I wanted. (Nice timesaver for people interested).
    He also made use of a very nice little framework from the guys at twitter called Bootstrap that helps quite a lot with look and feel for technical people like me. I found it very nice and useful for making your apps look quite slick when you are artistically impaired like myself.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s