相关疑难解决方法(0)

扩展Roles表后,实体类型IdentityRole不是当前上下文的模型的一部分

我将由实体框架创建的AspNetRoles扩展为如下所示:

public class AspNetRoles:IdentityRole
{
        public AspNetRoles() : base() { }
        public String Label { get; set; }
        public String ApplicationId { get; set; }
        public AspNetApplications Application { get; set; }

        public static readonly String SystemAdministrator = "SystemAdministrator";
}
Run Code Online (Sandbox Code Playgroud)

我知道,因为我已经扩展了identityrole表,所以必须对usermanager进行更改。这是我所做的:

public class ApplicationUserManager : UserManager<ApplicationUser>
{
    public ApplicationUserManager(IUserStore<ApplicationUser> store)
        : base(store)
    {
    }

    public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context) 
    {
        var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
        // Configure validation logic for usernames
        manager.UserValidator = new UserValidator<ApplicationUser>(manager)
        {
            AllowOnlyAlphanumericUserNames …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc entity-framework

4
推荐指数
1
解决办法
1073
查看次数

标签 统计

asp.net ×1

asp.net-mvc ×1

c# ×1

entity-framework ×1