Change table column names created by Asp.Net Identity

Asked

Viewed 700 times

3

My doubt is simple, but I am not able to solve it. It is possible to change the table columns name Aspnetusers that Identity creates in the database?

Another question is, how to add new fields in this same table and one of them will be related to another table?

I am working with Entity Framework Code First.

Thanks for the help.

1 answer

4


You can change the name of the columns in the Aspnetusers table that Identity creates in the database?

No. Column names are essential for a security check by IdentityDbContext at the initialization of the context (see here from lines 127 to 132).

You can rename tables if you want. I explain it here.

Another question is, how to add new fields in this same table and one of them will be related to another table?

Deriving the entity:

public class Usuario : IdentityUser 
{
    public String InformacaoNova1 { get; set; }
    public String InformacaoNova2 { get; set; }
    public String InformacaoNova3 { get; set; }
}

And typifying the context with your class Usuario:

public class MeuContexto : IdentityDbContext<Usuario> { ... }

I do a demonstration of how to change some more aspects of ASP.NET Identity here.

  • Thanks Gypsy Morrison. Great tips on the links presented.

Browser other questions tagged

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