I am getting the weirdest error. I'm using code first to initial my database. I have 2 entities that have a many to many relationship. If I attempt to initialize either ICollection in the constructor I get the following error when trying trying to use the context to add a value (initially build the database vie entity framework)
The number of members in the conceptual type 'ClubCraftManager.DataAccess.Club' does not match with the number of members on the object side type 'ClubCraftManager.Model.Models.Club'. Make sure the number of members are the same.
public class Club
{
public Club()
{
this.ClubCrafters = new List<Crafter>();
}
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual Guid ClubIdGuidId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
public Guid ClubMangerId { get; set; }
[ForeignKey("ClubMangerId")]
public virtual Crafter ClubManager { get; set; }
public virtual ICollection<Crafter> ClubCrafters { get; }
}
If I leave the classes as the following no error, but I hate not initialing Collections and or lists, leaves yourself open for null values later on....
public class Club
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual Guid ClubIdGuidId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
public Guid ClubMangerId { get; set; }
[ForeignKey("ClubMangerId")]
public virtual Crafter ClubManager { get; set; }
public virtual ICollection<Crafter> ClubCrafters { get; set; }
}
Any idea what's going on here...?