I have a simple relationship. A campaign is linked to two Pages. A page can only be linked to one campaign. But I keep running into this error:
System.Data.Edm.EdmAssociationEnd: : Multiplicity is not valid in Role 'Page_Campaign_Source' in relationship 'Page_Campaign'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be '*'.
I went looking through some example codes and tutorials while comparing it to my code but I can't find a mistake.
public class Campaign
{
[Key()]
public int Campaignid { get; set; }
public string Name { get; set; }
public virtual Page LandingPage { get; set; }
public virtual RedeemPage RedeemPage { get; set; }
}
public class Page
{
[Key()]
public int PageContentId { get; set; }
public string Logo { get; set; }
public string Css { get; set; }
[ForeignKey("Campaign")]
public int campaignID { get; set; }
public virtual Campaign Campaign { get; set; }
}
Edit
Followed Eranga's reply and used the Fluent API instead but now I'm getting:
An error occurred while saving entities that do not expose foreign key properties for their relationships
RedeemPage
really another class? Or should it be actuallyPage
?