我正在尝试在我的MVC3模型中使用复合键,但我无法构建它。谁能发现我哪里出错?我已经设法在普通的SQL Server中构建它,所以我知道它是有效的。添加PhonePair模型时,它无法构建PhonePair控制器
非常感谢
public class Installation
{
[Key]
[Column(Order = 0)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int InstallationID { get; set; }
public string Name { get; set; }
}
public class TagGuest
{
[Key]
[Column(Order = 0)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int TagGuestID { get; set; }
[Key]
[Column(Order = 1)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[ForeignKey("Installation")]
public int InstallationID { get; set; }
public virtual Installation Installation { get; set; }
public string Description { get; set; }
}
public class TagLocation
{
[Key]
[Column(Order = 0)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int TagLocationID { get; set; }
[Key]
[Column(Order = 1)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[ForeignKey("Installation")]
public int InstallationID { get; set; }
public virtual Installation Installation { get; set; }
public string Description { get; set; }
public int AudioID { get; set; }
public virtual Audio Audio { get; set; }
}
public class Audio
{
public int AudioID { get; set; }
public string URL { get; set; }
}
public class PhonePair
{
[Key]
[Column(Order = 0)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public string IPAddress { get; set; }
[Key]
[Column(Order = 1)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[ForeignKey("TagGuest")]
public int TagGuestID { get; set; }
public int InstallationID { get; set; }
public virtual TagGuest TagGuest { get; set; }
public string Description { get; set; }
}