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将会是一个整数类型。

相关内容

热门资讯

透视有挂!wepoker私人局... 透视有挂!wepoker私人局辅助器怎么用(透视)hhpkoer辅助器视频,教程指南书(有挂秘笈)-...
透视推荐!aapoker透视怎... 透视推荐!aapoker透视怎么用(透视)智星德州插件2024最新版,教程法子(真的有挂)-哔哩哔哩...
透视普及!hhpoker透视码... 透视普及!hhpoker透视码(透视)aapoker公共底牌,教程模板(有挂规律)-哔哩哔哩1、上手...
透视揭露!hhpoker有没有... 透视揭露!hhpoker有没有开挂(透视)pokemmo辅助器手机版下载,教程步骤(有挂秘诀)-哔哩...
透视了解!hhpkoer辅助挂... 透视了解!hhpkoer辅助挂是真的吗(透视)哈糖大菠萝攻略,教程学习(证实有挂)-哔哩哔哩1、金币...
透视解迷!约局吧怎么看有没有挂... 透视解迷!约局吧怎么看有没有挂(透视)wepoker有没有机器人,教程窍门(确实有挂)-哔哩哔哩亲,...
透视推荐!wepokerplu... 透视推荐!wepokerplus透视脚本免费(透视)菠萝德州透视脚本,教程教材(存在有挂)-哔哩哔哩...
透视辅助!wepoker辅助器... 透视辅助!wepoker辅助器安装包(透视)wepoker插件程序激活码,教程阶段(有挂分析)-哔哩...
透视总结!wepoker安装教... 透视总结!wepoker安装教程(透视)约局吧开挂神器是真的吗,教程方式(有挂猫腻)-哔哩哔哩所有人...
透视详细!wepoker辅助器... 透视详细!wepoker辅助器安装包(透视)wepoker辅助器安装包,教程手筋(竟然有挂)-哔哩哔...