更新时间:2023-02-25 21:54:43
由于您的最后建议,看来我已经找到了错误!我正在尝试设置外键的值,如果ID ...
It seems I've found the error thanks to your last suggestion! I was trying to set the value of the foreign key instead if the ID...
对我有用的代码:
[HttpPost]
public async Task<ActionResult> Register(RegisterViewModel model)
{
// verify the models' valid
if (ModelState.IsValid)
{
var user = new ApplicationUser {
/* ... */,
CompanyID = model.CompanyID // entity we retrieved
};
//
// SignInManager yatta yata
//
}
return View(model); // Uh-oh fallback.
}