У меня есть следующие классы (сокращенные для краткости);Проблема с миграцией базы данных на платформе Entity 6
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; }
}
Теперь, когда я пытаюсь запустить мою команду update-database
я получаю эту ошибку:
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 '*'.
Может кто-нибудь, пожалуйста, посоветуйте, что я делаю неправильно здесь?
Я чувствую перекрестное отношение между классами. Класс «InsurancePolicy» относится к классу «Устройство» одновременно, и он обращается назад. Я думаю, что это неприемлемо. Просьба оптимизировать отношение таблицы –