I'm using the ASP.NET SQL Membership Provider. So, there's an aspnet_Users
table that has details of each of my users. (Actually, the aspnet_Membership
table seems to contain most of the actual data).
I now want to store some per-user information in my database, so I thought I'd just create a new table with a UserId
(GUID) column and an FK relationship to aspnet_Users
. However, I then discovered that I can't easily get access to the UserId
since it's not exposed via the membership API. (I know I can access it via the ProviderUserKey
, but it seems like the API is abstracting away the internal UserID
in favor of the UserName
, and I don't want to go too far against the grain).
So, I thought I should instead put a LoweredUserName
column in my table, and create an FK relationship to aspnet_Users
using that. Bzzzt. Wrong again, because while there is a unique index in aspnet_Users
that includes the LoweredUserName
, it also includes the ApplicationId
- so in order to create my FK relationship, I'd need to have an ApplicationId
column in my table too.
At first I thought: fine, I'm only dealing with a single application, so I'll just add such a column and give it a default value. Then I realised that the ApplicationId
is a GUID, so it'd be a pain to do this. Not hard exactly, but until I roll out my DB I can't predict what the GUID is going to be.
I feel like I'm missing something, or going about things the wrong way. What am I supposed to do?