我正在尝试更新到.NET Core 2.0,但会弹出几个错误:
问题:
我有两个类,ApplicationRole和ApplicationUser,它继承IdentityRole和IdentityUser的一些属性.
随着Core 2.0的更新,我收到以下错误,声称无法找到IdentityRole和IdentityUser.
但是,该软件包Microsoft.AspNetCore.Identity.EntityFrameworkCore 2.0安装在新版本的.NET Core中
关于IdentityRole:
消息1:
找不到类型或命名空间名称'IdentityRole'(是否缺少using指令或程序集引用?)
消息2:
'Application.Models.ApplicationRole'类型不能用作泛型类型或方法'IdentityDbContext'中'TRole'类型的参数.没有从"Application.Models.ApplicationRole"到"Microsoft.AspNetCore.Identity.IdentityRole"的隐式引用转换.
ApplicationRole的定义:
public class ApplicationRole:IdentityRole
{
public string Description { get; set; }
public DateTime CreatedDated { get; set; }
public string IPAddress { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
关于IdentityUser:
消息1:
找不到类型或命名空间名称'IdentityUser'(是否缺少using指令或程序集引用?)
消息2:
'Application.Models.ApplicationUser'类型不能用作泛型类型或方法'IdentityDbContext'中'TUser'类型的参数.没有从"Application.Models.ApplicationUser"到"Microsoft.AspNetCore.Identity.IdentityUser"的隐式引用转换.
ApplicationUser的定义
public class ApplicationUser:IdentityUser
{
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
下面的指南定义了这些类及其用法如下:
随着Core 2.0的改变,我想知道IdentityRole和IdentityUser是如何改变的,所以我不能再继承它们了.