Reputation: 147
I had issue with Entity Framework IdentityUser when override UserName and then try to create new user the UserName will not be saved in database even though the normlized username is saved.
Same issue happens to Email when I override.
I have been using it this way for years in many projects with no issues, but in this I couldn't find out why it is happening.
if I remove the override attribute then it will be saved in database fine, but i do need override.
Please assist.
Upvotes: 2
Views: 919
Reputation: 205
Did you pass your User class to the IdentityDbContext?
In the applicationDbContext where you inherit the IdentityDbContext, if you have your own specific User or Role classes you must pass these classes to the IdentityDbContext.
public class ApplicationDbContext: IdentityDbContext<UserClass, RoleClass, TKey>{}
And also in the StartUp.cs class, you must add these classes where you add identity services.
services.AddIdentity<UserClass, RoleClass>();
Upvotes: 2