Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends

Please support me to create an application using WebApi and AngularJs. I have newly started work on angular js and webApi. I understand all the way to work on same technology. Here i am using OWIN to authenticate Webapi and Client request. My problem is how to rename and Add default table [AspNetUsers] name and field. If you have any small application is based on these do share me. I am very tankful to you all.

What I have tried:

Dear Friends

Please support me to create an application using WebApi and AngularJs. I have newly started work on angular js and webApi. I understand all the way to work on same technology. Here i am using OWIN to authenticate Webapi and Client request. My problem is how to rename and Add default table [AspNetUsers] name and field. If you have any small application is based on these do share me. I am very tankful to you all.
Posted
Updated 26-Sep-16 4:44am
Comments
Suvendu Shekhar Giri 26-Sep-16 7:47am    
Have you started developmnet yet?

1 solution

So to rename AspNetUsers to a different table name you need to go into the file that contains your Identity Model. In that file, you should have an ApplicationDbContext as well. In the OnModelCreating method, this is where you will map your changes to what is provided by default.

C#
modelBuilder.Entity<IdentityUser>().ToTable("MyNewUserTable").Property(p => p.Id).HasColumnName("UserId");
modelBuilder.Entity<MyNewUserTable>().ToTable("MyNewUserTable").Property(p => p.Id).HasColumnName("UserId");
modelBuilder.Entity<IdentityUserRole>().ToTable("MyNewUserTableRoles");
modelBuilder.Entity<IdentityUserLogin>().ToTable("MyNewUserTableLogins");
modelBuilder.Entity<IdentityUserClaim>().ToTable("MyNewUserTableClaims");
modelBuilder.Entity<IdentityRole>().ToTable("MyNewUserTableRoles");


In my example I've renamed the AspNetUsers table to MyNewUserTable and I've also renamed all the default Identity framework tables as well.

For more information on this, here are some links

c# - How can I change the table names when using Visual Studio 2013 AspNet Identity? - Stack Overflow[^]

rename aspnetusers table - Google Search[^]
 
Share this answer
 
Comments
rajnish.d3006 27-Sep-16 6:09am    
Thank you very much.. It work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900