title: How to get an object with non-primitive parameters from Database.SqlQuery?
body: <p>Could you please advise what I should do in the question described below?</p>
  
  <p>I have a class "Car" that is mapped with database table (Using EF Code First) and <strong>it has only primitive object parameters</strong>.</p>
  
  <p>Also I have a second class "User" that is mapped with my database table too and this class has also object parameter Car.</p>
  
  <p>Could you please tell me, how I can get the first object from DB, used to the following code EF?</p>
  
  <pre><code>DbContext.Database.SqlQuery&lt;User&gt;("dbo.GetFirstUser")
  </code></pre>
  
  <p>My function <code>dbo.GetFirstUser</code>:</p>
  
  <pre><code>SELECT UserID, FirstName, SecondName, CarID FROM dbo.User
  </code></pre>
  
  <p>When I try to get it, my query returns object only with primitive parameters, <strong>object Car is always null</strong>.</p>
  
  <p>I will be thankful for your advice.</p>
  
  <p>Thanks.</p>
  
  <pre><code>using System.ComponentModel.DataAnnotations;
  using System.ComponentModel.DataAnnotations.Schema;
  
  namespace TestTimerConsole
  {
      [Table("Car", Schema = "usr")]
      class Car
      {
          [Key]
          public int CarID    { get; private set; }
          public string Name  { get; private set; }
      }
  }
  
  using System.ComponentModel.DataAnnotations;
  using System.ComponentModel.DataAnnotations.Schema;
  
  namespace TestTimerConsole
  {
      [Table("User", Schema = "usr")]
      class User
      {
          [Key]
          public int UserID           { get; private set; }
          public string FirstName     { get; private set; }
          public string SecondName    { get; private set; }
          [ForeignKey("Car")]
          public int CarID            { get; private set; }
          public Car Car              { get; private set; }
      }
  }
  </code></pre>