Why don't the UserManager of Identity recognize the Create method in configuration method?

Why don't the UserManager of Identity recognize the Create method in configuration method?

I am new to ASP.NET Identity and created a simple sign-in process and have registered the delegates in configuration method of IdentityConfig of my project.

I am new to ASP.NET Identity and created a simple sign-in process and have registered the delegates in configuration method of IdentityConfig of my project.

I am trying to register them but the UserManager and RoleManager classes are not recognizing the Create method.

public class IdentityConfig
{
    public void Configuration(IAppBuilder app)
    {
        app.CreatePerOwinContext<UserManager<AppUsers>>(UserManager<AppUsers>.Create);
        app.CreatePerOwinContext<RoleManager<AppRole>>(RoleManager<AppRole>.Create);

    app.CreatePerOwinContext(() =&gt; new UsersPhonesDBContext());

    app.CreatePerOwinContext&lt;RoleManager&lt;AppRole&gt;&gt;((options, context) =&gt;
        new RoleManager&lt;AppRole&gt;(
            new RoleStore&lt;AppRole&gt;(context.Get&lt;UsersPhonesDBContext&gt;())));

    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        LoginPath = new PathString("/Home/Login"),
    });
}

}

Login Method:

public ActionResult Login()
{
    var userManager = HttpContext.GetOwinContext().GetUserManager<UserManager<AppUsers>>();
    var roleManager = HttpContext.GetOwinContext().GetUserManager<RoleManager<AppRole>>();
    var authManager = HttpContext.GetOwinContext().Authentication;

AppUsers user = userManager.FindByName("MyName");
if (user != null)
{
    var ident = userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

    //use the instance that has been created. 
    authManager.SignIn(
        new AuthenticationProperties { IsPersistent = false }, ident);

    return Redirect(Url.Action("Index", "Rest"));
}

// AppUsers user= userManager.Find("Hunain","");
return View();

}

Update:

I wrote the class AppUserManager and method inside it:

public class AppUserManager: UserManager<AppUsers>
    {
        public AppUserManager(IUserStore<AppUsers> store): base(store)
        {
        }

    // this method is called by Owin therefore best place to configure your User Manager
    public static AppUserManager Create(
        IdentityFactoryOptions&lt;AppUserManager&gt; options, IOwinContext context)
    {
        var manager = new AppUserManager(
            new UserStore&lt;AppUsers&gt;(context.Get&lt;UsersPhonesDBContext&gt;()));

        // optionally configure your manager
        // ...

        return manager;
    }
}

Still

var manager = new AppUserManager(
                    new UserStore<AppUsers>(context.Get<UsersPhonesDBContext>()

throws error.

Value cannot be null.

My DB context class:

public class UsersPhonesDBContext: IdentityDbContext<AppUsers> { public UsersPhonesDBContext() : base("UsersPhonesDBContext") { Database.SetInitializer<UsersPhonesDBContext>(null); }

    public DbSet&lt;Users&gt; PhoneUsers { get; set; }
    public DbSet&lt;Phones&gt; Phones { get; set; }
    public DbSet&lt;Sims&gt; Sims { get; set; }
}


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Add asp.net Identity in empty project

LIKE | COMMENT | SHARE | SUBSCRIBE Today, in this tutorial you will see the process of adding an ASP.NET Identity to the ASP.NET Web Application developed in...

List all users from asp net core identity

LIKE | COMMENT | SHARE | SUBSCRIBE In this video, i will show you How to retrieve and display all the registered application users in asp.net core using the ...

Extend IdentityUser in ASP NET Core

LIKE | COMMENT | SHARE | SUBSCRIBE In this tutorials, I will show you how to extend IdentityUser in asp.net core.. Subscribe & Stay Connected! Thank You! ♥ #...