Multiplicity not allowed. Entity Framework

asp.net-mvc-4 entity-framework

Question

I am attempting to use MVC4 for the first time and am receiving the following error when I try to create a controller? Could someone kindly steer me in the right direction?


Microsoft Visual Studio

System.Data.Entity.Edm.EdmAssociationEnd: : Multiplicity is not valid in Role 'PropertyData_DNISData_Target' in relationship 'PropertyData_DNISData'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be '*'.

public class PropertyData
{
    [Key]
    public virtual string PropertyID { get; set; }

    [ForeignKey ("DNISData")]
    public virtual string DNIS { get; set; }

    public virtual string PropertyName { get; set; }
    public virtual string PropertyGreeting { get; set; }
    public virtual string PropertyOperator { get; set; }
    public virtual string InvalidEntryPrompt { get; set; }
    public virtual string NoEntryPrompt { get; set; }
    public virtual string Comment { get; set; }
    public virtual DNISData DNISData { get; set; }

}

public class DNISData
{
    [Key]
    public virtual string DNIS { get; set; }
    [ForeignKey("PropertyData")]
    public string PropertyID { get; set; }
    public virtual string VDN { get; set; }
    public virtual string PropertyGreeting { get; set; }
    public virtual string Comment { get; set; }
    public virtual PropertyData PropertyData { get; set; }
}

public class DigitData
{
    [ForeignKey ("DNISData")]
    [Key]
    public virtual string DNIS { get; set; }
    [Key]
    public virtual string Digit { get; set; }
    public virtual string InvalidEntryPrompt { get; set; }
    public virtual DNISData DNISData { get; set; }
}
1
8
10/9/2013 4:19:56 PM

Popular Answer

You have a 1 to 1 relationship between PropertyData and DNISData. This can only be done via shared primarykey in EntityFramework.

This question can give you the anwser you are looking for:

How to declare one to one relationship using Entity Framework 4 Code First (POCO)

2
5/23/2017 10:29:05 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow