[Table("RegistrationCodes")]
public class RegistrationCode
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
public Guid Code { get; set; }
public int? UserId { get; set; }
[ForeignKey("UserId")]
public UserProfile User { get; set; }
[StringLength(500)]
public string Notes { get; set; }
}
I 아래 코드로 내 DBSet에서 개체를 검색하면 UserId는 항상 null입니다.
return this.Context.RegistrationCodes.FirstOrDefault(c => c.Code == code);
나는 데이터베이스를 점검하고 UserId가 null이 아닌지 확인했다. 또한 프로파일 링을 통해 UserId가 데이터베이스에서 요청되었음을 알 수 있습니다.
도움을 주시면 감사하겠습니다. Ohhhhh 내, 내가 바보가 된 기분하지 않는
UserId 또는 UserProfile이 null입니까? –
UserId와 UserProfile 모두 null입니다. –