esac
esac

Reputation: 24685

How to create a relationship between ASP.Net MembershipServices user and other tables?

I am using MembershipServices. I have some other tables that I need to associate the records to the user. I created a relationship between aspnet_Users.UserId and MyTable.UserId which are both 'uniqueidentifier' in SQL.

The problem comes when I want to save or lookup a record by user. I am using

 customization.UserId = Membership.GetUser().ProviderUserKey;

But it reports a compilation error that you can't convert this to a Guid. I am not sure ProviderUserKey correlates.

How do I create this relationship successfully and reference it programatically?

Upvotes: 0

Views: 269

Answers (1)

deerchao
deerchao

Reputation: 10544

Just directly cast its type, everything will be OK:

object key = Membership.GetUser().ProviderUserKey;
customization.UserId = (Guid)key;

Upvotes: 1

Related Questions