1
I am using Asp.net Identity for authentication and authorization
I have my user class:
public class Usuario : IdentityUser<int, ApplicationUserLogin,ApplicationUserRole, ApplicationUserClaim>
{
}
public class ApplicationUserLogin : IdentityUserLogin<int> { }
public class ApplicationUserClaim : IdentityUserClaim<int> { }
public class ApplicationUserRole : IdentityUserRole<int> { }
I did this so I could use fk as Integer in Asp.net mvc and not Guid as the default.
My class of Role
public class Role : IdentityRole<int, ApplicationUserRole>,IRole<int>
{
}
But in my database table, it is generated:
UserId, RoleId, Usuario_Id
Why does this happen? What’s wrong?
This is giving problem because when I step to add a scroll to the user:
await _userManager.AddToRolesAsync(1, "Admin");
It fills the Userid column but the Userid does not, so if I fill it manually it works my authorization, otherwise it does not.
The name of the identification column in the derived class is equal to the inherited class. Therefore, the correct column is
UserId
, and notUsuarioId
.– Leonel Sanches da Silva
No @Tiagosilva, there is no User_id property in any of the used classes of Asp.net Identity
– Rod
It’s just like I showed @Tiagosilva, nothing different
– Rod
Just a detail I saw, if I use modelBuilder.Entity<Usuario>(). Totable("User"); It does not duplicate, but if I use a class with Entitytypeconfiguration it duplicates o_O
– Rod