Asp.net MVC 4 EF Code First Starter Membership Providers

Although I have asked a few questions about how to use membership providers with ASP.NET MVC 4, I hardly got any answer. It takes me a while (as a beginner) to get started with ASP.NET MVC 4 Membership Providers. I read the article trying to try, but only added to the confusion, not helped.

What are the answers to the following newbie queries:

  • I want to try all the membership providers (including the simple membership provider) before deciding which one to use for which project. What kind of membership providers can I use with ASP.NET MVC 4 and how can I customize each one. Any documentation or links?
  • Although the internet template comes with a pre-configured account controller that sets the membership functionality, but how can I add the membership functionality to the base template. What steps should I follow to set up membership with membership providers (I assume the set of steps / settings / settings will be different for different membership providers).
  • Running an ASP.NET MVC 4 project created with the Internet Project Template (without making any changes to it) creates 5 tables in the table, namely: UserProfile, webpages_Membership, webpages_OAthMembership, webpages_Roles, webpages_UsersInRoles). In AccountModel.cs

    I see a definition for just one, UserProfile. Where other tables are indicated. Do I always need to have all these tables in the database in order to use membership. Can I customize, rename, or not use some of them?
  • I don't see any web.config membership configuration for the internet project template still using membership. In some tutorial articles I've seen people customize it by adding it <membership></membership>

    to web.config. When do I need to add configuration settings to web.config, and when do I not need to?

I think membership providers are meant to make life easy for developers, but it complicates things for me. I know that I really need to study it and what I have been trying for the last 7, 8 days but cannot figure it out. Any help, links (hopefully not the ones I've gone through many times) are more than welcome.

+3


source to share


2 answers


I agree with you as far as what types of memberships do that just sucks.

  • You can use any of the providers with ASP MVC. The default template in Visual Studio, which is an Internet MVC application, is the only one using SimpleMembership.

  • Good question, I haven't found any explicit, decent documentation at all. As far as I can tell, most of the membership elements are very similar.

  • At the very least SimpleMembership will create the necessary DB tables that are needed if they don't exist. I think the only one you can really customize is your custom table.

  • I think like sql tables, membership tags in web.config are implied. If you accept the defaults, they magically work.



The best link I found is http://blog.longle.net/2012/09/25/seeding-users-and-roles-with-mvc4-simplemembershipprovider-simpleroleprovider-ef5-codefirst-and-custom-user- properties /

There are two more in this post that are helpful.

+3


source


For question 3, I tried something and it turned out that:

Yes . You can add new columns to UserProfile (and all other tables I think)



No . You cannot rename the table even if you changed the codes in the AccountModels to match the new table names. In this case, when the application starts, a set of tables with the old names will be created. And all codes provided by MVC4 (MembserShip, WebSecurity, Users, Roles ....) will use the old tables.

And I never found any information on how to rename these tables.

+1


source







All Articles