There are 2 tables, many-to-many relationships between them:

public class Film { public Film() { Actors_FIlm = new List<Actors>(); } [Key] public int ID { get; set; } //Какие-то данные public virtual ICollection<Actors> Actors_FIlm { get; set; } } public class Actors { public Actors() { Films = new List<Film>(); } [Key] public int ID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public virtual ICollection<Film> Films { get; set; } } 

How can I do this so that the associated data is automatically loaded or should I always do this myself?

  • Do you have Code-First? - user218976
  • @Anamnian exactly. - Castiel_Luciefer2000 2:55 pm
  • Now the data is loaded when accessing the navigation property? What do you want? - Andrei NOP
  • 3
    It is better for you not to do in this case automatic loading of all navigation properties, since there will be a looping loadings of these properties. - user218976 pm
  • 2
    You need to do include (w => w.Actors_Film) if you need to load and actors, - Sultanov Shamil

0