I am trying to create code first approach a user table which have different foreign keys,but I it gives me error with this message:
"The ForeignKeyAttribute on property 'discount_id' on type 'EFNetflixAssignment.User' is not valid. The foreign key name 'Discounts' was not found on the dependent type 'EFNetflixAssignment.Discount'. The Name value should be a comma separated list of foreign key property names."
Here is my code for the user table
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Required]
public virtual int Id { get; set; }
[Required]
public virtual bool Status { get; set; }
[Required]
[MaxLength(255)]
public virtual string Email { get; set; }
[Required]
[MaxLength(255)]
public virtual string Password { get; set; }
[Required]
public virtual List<Payment_type> Payment_Types { get; set; }
[Required]
public virtual bool Activated { get; set; }
[Required]
[ForeignKey("Discounts")]
public virtual List<Discount> discount_id { get; set; }
}
And here is the discount code
public class Discount
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Required]
public virtual int Id { get; set; }
[Required]
[MaxLength(255)]
public virtual string discount_type { get; set; }
[Required]
public virtual decimal discount_amount { get; set; }
}
Can somebody help me solve this issue?