0

I want to add data in relational model

public class person
{
    public int id {get;set;}
    public string name {get;set;}
    public virtual ICollection<phone> Phones {get;set;}
}

public class Phone{
    public int id {get;set;}
    public string Phonenumber {get;set;}
    public int personid {get;set;}
    public virtual person Person {get;set;}             
    public virtual ICollection<phone> Phones {get;set;}
    
    public virtual ICollection<Address> Addresses {get;set;}
}

public class Address{
    public int id {get;set;}
    public string desc {get;set;}
}

when i fill

person.Phones[0].Addresses[0].desc= "1";

I have this error:

How do I resolve index was out of range. Must be non-negative and less than the size of the collection

ahmad
  • 1
  • 1

0 Answers0