我有一个ApplicationUser类,它扩展了IdentityUser。看起来像下面的
public partial class ApplicationUser : IdentityUser
{
[Display(Name = "Works For")]
public Client Client { get; set; }
}
这会导致我的AspNetUsers表具有以下内容,对我来说是正确的
ClientId-(FK,nvarchar(38)null)
但是,在我的控制器中,如果我尝试创建或更新,则不确定如何绑定
我使用...创建/更新用户
public async Task<IActionResult> Edit(string id, [Bind("Id, NormalizedEmail,NormalizedUserName, ClientId, ConcurrencyStamp")] ApplicationUser ApplicationUser)
{
//This code runs but the Client Id doesn't get updated
如果我做了我在其他任何班级所做的事情
public partial class ApplicationUser : IdentityUser
{
[Display(Name = "Works For")]
public Client Client { get; set; }
[ForeignKey("ClientId")]
public int ClientId { get; set; }
}
这导致我的AspNetUsers表具有以下内容
ClientId-(int,不为null) ClientId1-(FK,nvarchar(38)null)