I have the following problem. When debugging a project where I'm playing around a bit with Code First, the Items are somehow not added to the purchase. The purchases are added to the client.
This is how I seed the Data.
public class PublicDatabaseInitializer : DropCreateDatabaseIfModelChanges<PublicDataContext>
{
protected override void Seed(PublicDataContext context)
{
context.Clients.Add(new Client()
{
// ...
Purchases = new[]
{
new Purchase()
{
// ...
Items = new[]
{
new Item()
{
// ...
},
new Item()
{
// ...
}
}
},
new Purchase()
{
// ...
}
}
});
base.Seed(context);
}
}
And this is how I declare the two ICollection properties:
public virtual ICollection<Purchase> Purchases { get; set; }
public virtual ICollection<Item> Items{ get; set; }
I would be thankful for any help.