the model object is returning null : <p>I am using dotnet core 2.1.the problem is that when my database has values and I am querying it, it returns the value in the UserInteractions model but It says that the User Object is null. although it is not null.  my models and query are as below:</p>

<pre><code>public class UserInteractions {
public int Id { get; set; }
public int? UserId { get; set; }
[ForeignKey ("UserId")] public User user { get; set; }
public int? TargetId { get; set; }
[ForeignKey ("TargetId")] public User target { get; set; }
public int NumberOfMusicMedia { get; set; }
public int VolumeOfMusicMedia { get; set; }
public int NumberOfImageMedia { get; set; }
public int VolumeOfImageMedia { get; set; }
public int NumberOfVideoMedia { get; set; }
public int VolumeOfVideoMedia { get; set; }
public int NumberOfDocumentMedia { get; set; }
public int VolumeOfDocumentMedia { get; set; }
public bool IsMuted { get; set; } 
}

public class User {
[Key]
public int Id { get; set; }
public string Phone { get; set; }
public string Name { get; set; }
public string UserName { get; set; }
}
</code></pre>

<p>this is my query:</p>

<pre><code>var mediaInfo =  _db.UserInteractions.FirstOrDefault (o =&gt; o.UserId == 2);
User inf = mediaInfo.target;
</code></pre>

<p>it says that inf is null, but it should not be null</p>
