I'm just starting out learning ASP.NET MVC. I'm working on a project created with the standard project template which by default uses a SqlMembershipProvider
. This has automatically created a ASPNETDB.mdf database in my project to hold membership information. How can I associate the members stored in this database with my actual application data?
Should I simply reference the current user's name in my action methods using this.User.Identity.Name
to use as a key when storing or retrieving user specific information to and from my application's database? Or should I be using this.User.Identity.UserId
instead? I always thought integer based IDs were much faster to look up vs string or GUID base IDs. But the primary key of the aspnet_Users table is a GUID field.
Is there any difference between this.user
vs this.HttpContext.User
? What about the IPrincipal
returned from these properties vs the MembershipUser
returned from Membership.GetUser()
. What is the difference between these?
Also, is it best to keep the membership information in a separate database from the application database? Or is it ok to merge them together into a single database?