Why does my Asp.net mvc tables have pk duplicated user?

Asked

Viewed 108 times

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 not UsuarioId.

  • No @Tiagosilva, there is no User_id property in any of the used classes of Asp.net Identity

  • It’s just like I showed @Tiagosilva, nothing different

  • 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

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.