I have to use a Guid for the UserProfile's UserId. But this gives me a type conversion exception (int <-> Guid) during Login. Any chance to use SimpleMembership without an int typed UserId ?
Stack-Trace:
bei CallSite.Target(Closure , CallSite , Object )
bei WebMatrix.WebData.SimpleMembershipProvider.GetUserId(IDatabase db, String userTableName, String userNameColumn, String userIdColumn, String userName)
bei WebMatrix.WebData.SimpleMembershipProvider.VerifyUserNameHasConfirmedAccount(IDatabase db, String username, Boolean throwException)
bei WebMatrix.WebData.SimpleMembershipProvider.ValidateUser(String username, String password)
bei System.Web.Security.Membership.ValidateUser(String username, String password)
bei WebMatrix.WebData.WebSecurity.Login(String userName, String password, Boolean persistCookie)
Changed UserProfile:
[Table("WebAccounts")]
public class UserProfile
{
[Key]
[Column("ID")]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public Guid UserId { get; set; }
//public int UserId { get; set; }
[Column("P_Username")]
public string UserName { get; set; }
}
maxloc
0 Points
2 Posts
MVC4: SimpleMembership UserProfile with Guid
Feb 01, 2013 11:13 AM|LINK
Hi,
I have to use a Guid for the UserProfile's UserId. But this gives me a type conversion exception (int <-> Guid) during Login. Any chance to use SimpleMembership without an int typed UserId ?
Stack-Trace:
Changed UserProfile:
[Table("WebAccounts")] public class UserProfile { [Key] [Column("ID")] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public Guid UserId { get; set; } //public int UserId { get; set; } [Column("P_Username")] public string UserName { get; set; } }
molly_c
Participant
1590 Points
401 Posts
Re: MVC4: SimpleMembership UserProfile with Guid
Feb 08, 2013 08:08 AM|LINK
I don't think so, maxloc. int and Guid are different data type, int store numbers, Guid store 16-bit characters , why do you convert them?
Molly
It's time to start living the life you are imagined.
maxloc
0 Points
2 Posts
Re: MVC4: SimpleMembership UserProfile with Guid
Feb 08, 2013 08:20 AM|LINK
Hi,
because I wanted to use the Simple-/ExtendedMembershipProvider but cannot change the DB structure which uses "uniqueidentifier" as primary key.
Meanwhile, I found a nice example of custom Membership with MVC4: github.com/mazhekin/MVC4CustomMembershipSolution
So I added a unique key (integer) to the table and use custom data access logic. I just don't get why MS call it SimpleMembershipProvider
Regards, Max