I am trying to get multiple "units" to have a set of "UnitInfo" assigned but I get the following message from EF when using code first:
One or more validation errors were detected during model generation: Unit_UnitInfo_Source: : Multiplicity is not valid in Role 'Unit_UnitInfo_Source' in relationship 'Unit_UnitInfo'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be ''. SubUnit_UnitInfo_Source: : Multiplicity is not valid in Role 'SubUnit_UnitInfo_Source' in relationship 'SubUnit_UnitInfo'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be ''.
The classes I use looks like this:
public class Unit
{
public int UnitId { get; set; }
public string Name { get; set; }
public List<SubUnit> SubUnits { get; set; }
[ForeignKey("UnitInfoId")]
public UnitInfo UnitInfo { get; set; }
}
public class SubUnit
{
public int SubUnitId { get; set; }
public string Name { get; set; }
[ForeignKey("UnitInfoId")]
public UnitInfo UnitInfo { get; set; }
}
public class UnitInfo
{
public int UnitInfoId { get; set; }
public string Function { get; set; }
public string Location { get; set; }
}
Im sure that it is a simple mistake, I just cant figure it out.
What am I doing wrong?