I am creating a system that requires a user to approve actions in an application. One of the actions is adding a user the work flow is as follows.
- An existing user adds a new user.
- This action creates a row in the user table and a row in the linked approval table.
- When the user logs in if they have not been approved it will be rejected.
The problem is I get the following error
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 '*'.
This seems to be due to a circular foreign key my classes are as follows:
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; }
}
Any help would be awesome.