I have the following classes (shortened for brevity);
public class InsurancePolicy : AuditableEntity<int>
{
[Column("id"), Key]
public override int ID { get; set; }
[Column("deviceid"), ForeignKey("Device")]
public int DeviceId { get; set; }
public virtual Device Device { get; set; }
}
public partial class Device : AuditableEntity<int>
{
[Column("deviceid"), Key]
public override int ID { get; set; }
[ForeignKey("Policy")]
public int PolicyId { get; set; }
public virtual InsurancePolicy Policy { get; set; }
[ForeignKey("Vehicle")]
public int VehicleId { get; set; }
public virtual Vehicle Vehicle { get; set; }
}
public partial class Vehicle : AuditableEntity<int>
{
[Column("id"), Key]
public override int ID { get; set; }
[Column("deviceid"), ForeignKey("Device")]
public int DeviceId { get; set; }
public virtual Device Device { get; set; }
public virtual List<InsurancePolicyVehicle> InsurancePolicyVehicles { get; set; }
}
Now when I try and run my update-database command I get this error:
Device_Policy_Target: : Multiplicity is not valid in Role 'Device_Policy_Target' in relationship 'Device_Policy'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be '*'.
Device_Vehicle_Target: : Multiplicity is not valid in Role 'Device_Vehicle_Target' in relationship 'Device_Vehicle'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be '*'.
Could anyone please advise what I am doing wrong here?