There is:

public class contextNs :DbContext{ DbSet<User> Users{get;set;} DbSet<Message> Messages{get;set;} } public class User{ public int Id {get;set;} public string Name {get;set;} } public class Message{ public int Id{get;set;} public string text{get;set;} public User User{get;set;} } 

When passing to the representation of the Message class object, the User property (User = null) disappears from it. When working in the controller, this property is present.

  • 3
    I have, the code in it is an error: but I will not enter it into your question, but I will show another one. :) The question is incomplete, add code. - AK
  • There is a lot of code, I dropped the main thing, maybe the question is worth asking. Question: Is it possible that when passing an object to a view, the links that were in its properties cease to be valid, since for example, the namespace can change and so on. Those. in the view, this link points to a non-existent object. I think so, but I do not know right or wrong. - Belenot
  • >> The pointer to the object is disappearing. << o_O Pointers disappear, links are not referenced, constructors are not constructed. Anarchy in sisharpa. Essentially - when transferring an entity to a database, who indicates what - both the database itself and the entity services on the drum, references are the object part of the ORM, only you need them. The database and entity services use only identifiers of entities for communication (classical id, for example). - test123
  • Show to start the part of the action in which you make a request to the database. You have something like var model = this.Db.Messages.Include(x => x.User).FirstOrDefault(); return this.View(model); var model = this.Db.Messages.Include(x => x.User).FirstOrDefault(); return this.View(model); or work with the database highlighted in the repository? - AK

0