Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core mvc asp.net mvc将自定义列添加到标识角色表_Asp.net Core Mvc_Identityserver4 - Fatal编程技术网

Asp.net core mvc asp.net mvc将自定义列添加到标识角色表

Asp.net core mvc asp.net mvc将自定义列添加到标识角色表,asp.net-core-mvc,identityserver4,Asp.net Core Mvc,Identityserver4,这就是我如何向标识角色表添加新列的方法 public class ApplicationRole : IdentityRole { public ApplicationRole() : base() { } public ApplicationRole(string name, long customId) : base(name) { this.CustomId= customId; } public virtual long Cust

这就是我如何向标识角色表添加新列的方法

 public class ApplicationRole : IdentityRole
{
    public ApplicationRole() : base() { }
    public ApplicationRole(string name, long customId) : base(name)
    {
        this.CustomId= customId;
    }
    public virtual long CustomId{ get; set; }
}
在dbContext中,我添加了

 modelBuilder.Entity<ApplicationRole>().ToTable("AspNetRoles");
我在这里找不到新添加的列
CustomId

有没有我错过的一步

更新

使用@Chirs的答案,我可以得到
CoustomId
,但是当我运行时,我得到了这个错误

Cannot create a DbSet for 'IdentityRole' because this type is not included in the model for the context

如果您使用的是自定义标识模型,则还需要继承其中一个泛型
IdentityDbContext
类,并在相应的类型参数中指定自定义类型。在这种情况下,您只需要以下内容:

public class MyDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, string>

如果您使用的是自定义标识模型,则还需要继承其中一个泛型
IdentityDbContext
类,并在相应的类型参数中指定自定义类型。在这种情况下,您只需要以下内容:

public class MyDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, string>

这真的很有帮助,另外,请解释为什么
TKey
保留为
string
,我们应该在什么时候定义它?:)当我运行
无法为“IdentityRole”创建DbSet时,我遇到了这个错误,因为上下文的模型中没有包含这种类型的DbSet
,这真的很有帮助,另外,请解释为什么
TKey
保留为
字符串,我们应该在什么时候为它定义?:)当我运行
无法为'IdentityRole'创建DbSet时,我遇到了这个错误,因为上下文的模型中不包括这种类型
private readonly MyDbContext db_Identity;