ASP.Net.Core 2.2 Identity将ID从字符串改为整数
创始人
2024-09-17 02:30:37
0

在ASP.Net Core 2.2 Identity中,可以通过自定义User类来将ID从字符串改为整数。以下是一个解决方案的代码示例:

  1. 创建一个自定义的User类,继承自IdentityUser
public class ApplicationUser : IdentityUser
{
}
  1. 在Startup.cs文件的ConfigureServices方法中,将默认的IdentityUser类替换为自定义的User类:
services.AddDefaultIdentity()
    .AddEntityFrameworkStores()
    .AddDefaultTokenProviders();
  1. 在DbContext类中将IdentityUser替换为ApplicationUser:
public class ApplicationDbContext : IdentityDbContext
{
    public ApplicationDbContext(DbContextOptions options)
        : base(options)
    {
    }
}
  1. 在Identity的数据库迁移中,将IdentityUser替换为ApplicationUser:
dotnet ef migrations add InitialCreate

这样,你的ASP.Net Core 2.2 Identity中的UserID将会是一个整数类型。

相关内容

热门资讯

第4分钟手段!wepoker好... 第4分钟手段!wepoker好友局透视(透视)都是有辅助开挂(哔哩哔哩)1、下载好wepoker好友...
2分钟要领!wpk透视辅助方法... 2分钟要领!wpk透视辅助方法(透视)一直有辅助教程(哔哩哔哩)1、金币登录送、破产送、升级送、活动...
第一分钟模块!wepoker透... 第一分钟模块!wepoker透视底牌脚本(透视)切实真的是有辅助辅助(哔哩哔哩)一、wepoker透...
第9分钟绝活儿!红龙poker... 第9分钟绝活儿!红龙poker作必弊指令(透视)竟然存在有辅助工具(哔哩哔哩)一、红龙poker作必...
第3分钟办法!哈糖大菠萝破解器... 第3分钟办法!哈糖大菠萝破解器(透视)总是是有辅助教程(哔哩哔哩)1、进入到哈糖大菠萝破解器是否有挂...
四分钟步骤!wejoker辅助... 四分钟步骤!wejoker辅助软件视频(透视)确实存在有辅助神器(哔哩哔哩)进入游戏-大厅左侧-新手...
6分钟攻略!wejoker辅助... 6分钟攻略!wejoker辅助软件(透视)都是是真的有辅助透视(哔哩哔哩)wejoker辅助软件辅助...
第五分钟指南书!hhpoker... 第五分钟指南书!hhpoker免费透视脚本(透视)其实是真的有辅助教程(哔哩哔哩)1)hhpoker...
第九分钟绝活!wepoker有... 第九分钟绝活!wepoker有没有机器人(透视)一贯是有辅助教程(哔哩哔哩)1、wepoker有没有...
第9分钟讲义!wepoker透... 第9分钟讲义!wepoker透视底牌脚本(透视)总是真的是有辅助透视(哔哩哔哩)1、许多玩家不知道w...