views:

38

answers:

2

Hi. How does the default template for asp.net mvc store accounts (the AccountController)? Can I add unique numbered ids, since so far I have found out, that it uses unique login as primarz key? Is there a table containing these accounts? And which classes should I look for to work with them?

Thanks in advance.

A: 

The default MVC app will generate an ASPNETDB.MDF file in the App_Data directory when the first person registers. This contains the "standard" ASP.NET SQL membership schema, which ties in with the various MembershipProvider classes.

I've not really worked with the SQL membership stuff, but I imagine you could extend the schema and the classes to suit yourself.

Why do you need a unique id rather than using the default?

Chris
+1  A: 

It doesn't use the unique login as the primary key, not really. Under the hood there's a provider specific membership identifier, which in the case of the SQL membership provider is a GUID.

    MembershipUser membershipUser = Membership.GetUser();
    object userKey = membershipUser.ProviderUserKey;

In fact it's even more complicated than that, as you can have multiple applications sharing a membership database, either sharing the users, or using an application name to distinguish their users from each other, but calling ProviderUserKey will get the right result every time.

blowdart