Relate Identity table (AspNetUser) with other table in my application

0
I am developing an application that uses Asp.Net MVC Identity, I have isolated the Identity part in the CrossCutting layer, and created a layer called Data where I have the Entity Framework where I am mapping other tables that I will use in the (both the Identity and the Data point to the same database) I want to make a relationship from the AspNetUser table with the Service table, but when I run the Update-Database on the Package Console the following error occurs:

  

Data.Context.IdentityUserLogin:: EntityType 'IdentityUserLogin' has no key defined. Set the key for this EntityType.   Data.Context.IdentityUserRole:: EntityType 'IdentityUserRole' has no key defined. Set the key for this EntityType.   IdentityUserLogins: EntityType: EntitySet 'IdentityUserLogins' is based on type 'IdentityUserLogin' that has no keys defined.   IdentityUserRoles: EntityType: EntitySet 'IdentityUserRoles' is based on type 'IdentityUserRole' that has no keys defined.

Service Entity (Simplified):

 public class Servico
{
    public int Id { get; set; }
    public string Nome { get; set; }

    public virtual ApplicationUser Usuario { get; set; }
}

Identity OnModelCreating:

 protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.Entity<IdentityUser>()
            .ToTable("Usuarios")
            .Property(p => p.Id)
            .HasColumnName("UsuarioId");


        modelBuilder.Entity<ApplicationUser>()
            .ToTable("Usuarios")
            .Property(p => p.Id)
            .HasColumnName("UsuarioId");

        modelBuilder.Entity<IdentityUserRole>()
            .ToTable("UsuarioPapel");

        modelBuilder.Entity<IdentityUserLogin>()
            .ToTable("Logins");

        modelBuilder.Entity<IdentityUserClaim>()
            .ToTable("Claims");

        modelBuilder.Entity<IdentityRole>()
            .ToTable("Papeis");
    }
    
asked by anonymous 09.03.2018 / 14:29

0 answers