我正在尝试连接Company
和ApplicationUser : IdentityUser
之间的一对多关系。在我的ApplicationUser
课程中,我有:
public class ApplicationUser : IdentityUser
{
[ForeignKey("CompanyId")]
public int CompanyId { get; set; }
}
public class Company
{
[Key]
public int CompanyId { get; set; }
public string Name { get; set; }
...
}
但我收到了System.ArgumentException:
Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory 1[TContext]' violates the constraint of type 'TContext'
答案 0 :(得分:0)
您可以像这样设置关系。
public class ApplicationUser : IdentityUser
{
public Company Company { get; set; }
}