title: EF complex class getting me null
body: <p>I have a class like this. </p>
  
  <pre><code>public class User
  {
      public int Id { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public string Email { get; set; }
      public IList&lt;Role&gt; Roles { get; set; }
      public virtual Branch Branch { get; set; }
      public string Password { get; set; }
  }
  
  public class Branch
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public string Location { get; set; }
      public virtual Region Region { get; set; }
  }
  </code></pre>
  
  <p>The problem I have is that when I pass user as parameter to a repository layer method Branch property appears in null. I've verified that before it arrives to the repository it's not null. I think is something with serialization, but i'dont know how to fix it.</p>
  
  <p>Thanks in advance!</p>
  
  <p>This is the way the repository get objects:</p>
  
  <pre><code>public readonly IDbSet&lt;T&gt; DbSet;
  public IEnumerable&lt;T&gt; Find(Expression&lt;Func&lt;T, bool&gt;&gt; predicate, string sortColumn = null, bool sortDirection = true, params  string[] includes)
      {
          if (sortColumn == null)
          {
              var resultSet = GetDbSet(includes).Where(predicate);
              resultSet.ForEachAsync(e =&gt; Detach(e)).Wait();
              return resultSet;
          }
          else
              return OrderByField&lt;T&gt;(GetDbSet(includes).Where(predicate), sortColumn, sortDirection);
      }
      private IQueryable&lt;T&gt; GetDbSet(params string[] includes)
      {
          IQueryable&lt;T&gt; resultSet = DbSet;
  
          foreach (string include in includes)
              resultSet = resultSet.Include(include);
  
          return resultSet;
      }
  
      private T Detach(T entity)
      {
          System.Diagnostics.Contracts.Contract.Requires(entity != null);
  
          var entry = Context.Entry(entity);
          entry.State = System.Data.Entity.EntityState.Detached;
          return entity;
      }
  </code></pre>