【发布时间】:2015-02-13 17:18:50
【问题描述】:
我正在创建一个要求用户批准应用程序中的操作的系统。其中一项操作是添加用户,工作流程如下。
- 现有用户添加新用户。
- 此操作在用户表中创建一行,在链接的批准表中创建一行。
- 当用户登录时如果他们没有被批准将被拒绝。
问题是我收到以下错误
ApplicationUser_Approval_Source: : Multiplicity is not valid in Role 'ApplicationUser_Approval_Source' in relationship 'ApplicationUser_Approval'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be '*'.
这似乎是由于循环外键我的类如下:
public class Approval
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public bool IsApproved { get; set; }
public virtual IApprovalAction Action { get; protected set; }
public virtual ApplicationUser RequestingUser { get; set; }
}
public class ApplicationUser : IdentityUser<string, IdentityUserLogin, ApplicationUserRole, IdentityUserClaim>, IUser, IUser<string>, IApprovalAction
{
[ForeignKey("Approval")]
public int ApprovalId { get; set; }
public virtual Approval Approval { get; set; }
}
任何帮助都会很棒。
【问题讨论】:
标签: asp.net entity-framework ef-code-first asp.net-identity