How to Update Employee and Identity User with one to one/zero relation

后端 未结 2 1351
陌清茗
陌清茗 2021-01-28 16:45

I am trying to update employee record and want to update identity user too.

If i update Identity User first separately For Example:

UserManager.Update(u         


        
2条回答
  •  半阙折子戏
    2021-01-28 17:20

    Without seeing the exception, I'm not sure what the issue is, but you could trying using an attached entity and set values like the following.

     var dbEmployee = Context.Emplyoees.SingleOrDefault(s => s.Id == employee.Id);
     if (dbEmployee!= null)
     Context.Entry(dbEmployee).CurrentValues.SetValues(employee);
    

提交回复
热议问题