I'm learning aspnet.core and following tutorial related to IdentityServer4 for the Oauth2 server for the client app, in this case its react app.
After following the tutorial, I realise that all my tables has prefix AspNet
:
In IdentityServer4 docs though, I can see that they created tables with different prefix for different clients (API, Client). I've been trying to read the docs, search for the scaffolded templates that I got from:
dotnet new react -o <output_directory_name> -au Individual
But I can't find it anywhere. I even looked at the IdentityUser
class in the context from namespace using Microsoft.AspNetCore.Identity;
, and they have the table names without the prefix AspNet.
I'm coming from laravel, thus basically i have almost zero experience in c# and aspnet core. Can anyone help me explain?
Thanks
Don't get confused with Microsoft.Identity and IdentityServer4 . The tables that you are seeing with the prefix 'AspNet' from Microsoft Identity.
You can customize the way you want using the 'OnModelCreating' method of your DbContext. The below link has complete information on what you can do with Microsoft Identity. Identity model customization in ASP.NET Core
For Eg. below is some sample code from the above link to customize the table names
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<IdentityUser>(b =>
{
b.ToTable("MyUsers");
});
modelBuilder.Entity<IdentityUserClaim<string>>(b =>
{
b.ToTable("MyUserClaims");
});
modelBuilder.Entity<IdentityUserLogin<string>>(b =>
{
b.ToTable("MyUserLogins");
});
modelBuilder.Entity<IdentityUserToken<string>>(b =>
{
b.ToTable("MyUserTokens");
});
modelBuilder.Entity<IdentityRole>(b =>
{
b.ToTable("MyRoles");
});
modelBuilder.Entity<IdentityRoleClaim<string>>(b =>
{
b.ToTable("MyRoleClaims");
});
modelBuilder.Entity<IdentityUserRole<string>>(b =>
{
b.ToTable("MyUserRoles");
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.