Entity Framework Many to Many, why there is an extra entry?

Good day!
There are 2 tables of people and countries
public people()
{
 this.countries = new HashSet<countries>();
}

 public long id { get; set; }
 public string guid { get; set; }
 public string full_name { get; set; }
 public System.Date_birth DateTime { get; set; }
 public string birthplace { get; set; }
 public string birthplace_fias { get; set; }
 public string sex { get; set; }

 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadonly")]
 public virtual ICollection<countries> countries { get; set; }
 }</countries></countries>


public partial class countries
{
 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
 public countries()
{
 this.people = new HashSet<people>();
}

 public int id { get; set; }
 public string full_name { get; set; }
 public string name { get; set; }
 public string full_name_eng { get; set; }
 public string name_eng { get; set; }
 public string iso_num { get; set; }
 public string iso2 { get; set; }
 public string iso3 { get; set; }

 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadonly")]
 public virtual ICollection<people> people { get; set; }
 }</people></people>

When you add a new person, EF tries to create new record in the table countries, instead, it would just add an entry in the link table. Why?

ICollection<countries> countries = new Collection<countries>();

 countries.Add(new countries()
{
 id = 182,
 full_name = "Russia"
 name = "Russia"
 full_name_eng = "Russian Federation",
 name_eng = "Russia"
 iso_num = "643",
 iso2 = "RU"
 iso3 = "RUS"
});

peoplepdto = new people()
{
 birthplace = "Ufa",
 date_birth = DateTime.Today
 full_name = "Ivanov Ivan Ivanovich",
 guid = Guid.NewGuid().ToString(),
 sex = "M", 
 countries = countries
 };</countries></countries>
July 9th 19 at 10:09
1 answer
July 9th 19 at 10:11
Solution
I think here we should not create the object countries, but to get it from the database
ICollection<countries> countries = _countriesRepository.Get(...);

peoplepdto people = new people()
{
 birthplace = "Ufa",
 date_birth = DateTime.Today
 full_name = "Ivanov Ivan Ivanovich",
 guid = Guid.NewGuid().ToString(),
 sex = "M", 
 countries = countries
 };</countries>

Find more questions by tags C#Entity Framework