Sets have Cards and Sets. Here's what I have in my model, using EF Code First:
public class Set
{
// Primitive Properties
[Required]
[Key]
public virtual int SetId { get; set; }
// Navigation Properties
[Required]
public virtual List<Set> Sets { get; set; }
// Navigation Properties
[ForeignKey("ParentSet")]
public int ParentSetId { get; set; }
public virtual Set ParentSet { get; set; }
}
Then for Cards:
public class Card
{
// Primitive Properties
[Required]
[Key]
public virtual int CardId { get; set; }
// Navigation Properties
[Required]
[ForeignKey("ParentSet")]
public int ParentSetId { get; set; }
public virtual Set ParentSet { get; set; }
}
I'm trying to rebuild the database using 'update-database' from the package manager console and this is the error I'm getting:
Unable to determine the principal end of the
'App.Core.Set_ParentSet' relationship. Multiple added entities
may have the same primary key.
Any idea why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…