需要有关服务定义的帮助

Need help on Services definition

这些是我在 Controller 中的代码:

 public class IdentityUserController : Controller
{
    private readonly UserManager<DatabaseContext> _um;
    private readonly SignInManager<DatabaseContext> _sm;
    
    [HttpGet]
    public IActionResult Login()
    {       
        return View();
    }

    [HttpPost]
    public async Task<IActionResult> Login( Models.Person  lc)
    {

        if (ModelState.IsValid)
        {
             var result = await _sm.PasswordSignInAsync(lc.NationalCode, lc.Password, false, true);
            if (result.Succeeded)
            {
                TempData["LoggedUserCode"] = lc.NationalCode;
                ViewBag.LoggeduserDetails = lc.Name + " " + lc.Family;
                return RedirectToAction("Index","Home");
            }
            ModelState.AddModelError("", "User or Password not valid");
        }
        return View(lc);
    }

}

这些是启动配置中的代码:

  public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllersWithViews();
        services.AddDbContext<DatabaseContext>(option => option.UseSqlServer(@"Data Source =. ; Initial Catalog = LeaveSheet; Integrated Security=True;MultipleActiveResultSets=true "));
        services.ConfigureApplicationCookie(option => option.LoginPath = "/IdentityUser/Login");
    }

当我 运行 提交后,我在登录视图中出现以下错误:

NullReferenceException:对象引用未设置到对象的实例。

Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper 映射器、ObjectMethodExecutor 执行器、对象控制器、对象[] 参数) System.Threading.Tasks.ValueTask.get_Result() System.Runtime.CompilerServices.ValueTaskAwaiter.GetResult() Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker 调用程序,ValueTask actionResultValueTask) Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope 作用域, 对象状态, bool isCompleted) *

**你能帮帮我吗**

最后我决定改变我的数据库结构并从基础实现身份。