Hi
I am getting this error. I am trying to do a prototype and this is just from newly created application.
I have a first page which displays data in the grid. Then I have a context menu that calls the status page passing a parameter. I get this error, when I press arrow back. Appreciate any help. Thank you.
J
InvalidOperationException: The [InverseProperty] attribute on property 'UsersProfile.AssociateStatuses' is not valid. The property 'AssociateStatuses' is not a valid navigation on the related type 'AssociateStatus'. Ensure that the property exists and is a valid reference or collection navigation.
Table 1
[Table("AssociateStatus", Schema = "dbo")]
public partial class AssociateStatus
{
[Key]
[Required]
public int AssociateId { get; set; }
[Key]
[Required]
public DateTime StatusAsof { get; set; }
public string Notes { get; set; }
[Required]
public int CreatedBy { get; set; }
public int? ModifiedBy { get; set; }
public UsersProfile UsersProfile { get; set; }
public UsersProfile UsersProfile1 { get; set; }
Table 2
[Table("UsersProfile", Schema = "dbo")]
public partial class UsersProfile
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
[Required]
public string UserName { get; set; }
[Required]
public string UserPassword { get; set; }
[Required]
public string UserFullName { get; set; }
[Required]
public string UserEmailAddress { get; set; }
[Required]
public int UserStatusId { get; set; }
public ICollection<AssociateStatus> AssociateStatuses { get; set; }
public ICollection<AssociateStatus> AssociateStatuses1 { get; set; }
In my data context:
builder.Entity<JProvider.Models.jProvider.AssociateStatus>()
.HasOne(i => i.UsersProfile)
.WithMany(i => i.AssociateStatuses)
.HasForeignKey(i => i.CreatedBy)
.HasPrincipalKey(i => i.UserId);
builder.Entity<JProvider.Models.jProvider.AssociateStatus>()
.HasOne(i => i.UsersProfile1)
.WithMany(i => i.AssociateStatuses1)
.HasForeignKey(i => i.ModifiedBy)
.HasPrincipalKey(i => i.UserId);