Welcome,
I get the validation error mentioned in topic while creating (registering) new user in my Asp.Net mvc application where I used Asp.Net Identity with my custom ApplicationUser class
public class ApplicationUser : IdentityUser<string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>
{
public async Task<ClaimsIdentity>
GenerateUserIdentityAsync(ApplicationUserManager manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
public virtual string EmailConfirmedChar { get; set; }
public virtual string PhoneNumberConfirmedChar { get; set; }
public virtual string TwoFactorEnabledChar { get; set; }
public virtual string LockoutEnabledChar { get; set; }
}
where my TKey
is string, so I expect the Id
to be Guid
as it is by default.
Of course I implemented my custom UserStore, UserManager etc, in general I inspired by the blog post Customizing the ASP.NET Identity Data Model with the Entity Framework Fluent API
What do I do wrong ? Generaly the same validation error appears while downloaded the sample attached in this blog post.
Relevant or nor, I use Firebird database.
IdentityUser
class automatically generates GUID when you make a new instance of it. Not IdentityUser<TKey, TLogin, TRole, TClaim>
class.
However you could easily overcome this problem by generating new GUID in your ApplicationUser
class constructor:
public class ApplicationUser : IdentityUser<string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>
{
public ApplicationUser()
{
Id = Guid.NewGuid().ToString();
}
// rest of code
}