title: Lazy loading 2 objects in a Class - one gets loaded, other remains null
body: <p>I am using code first approach in Asp.net MVC using Entity framework. 
  I have Cart class in which i am using objects of 2 different classes, Product and UserProducts. They are virtual objects, that means they will be used by lazy loading.</p>
  
  <p>Following are my three classes:</p>
  
  <pre><code>public class Cart
  {
      [Key]
      public int Id { get; set; }
      public string CartId { get; set; }
      public int ProductId { get; set; }
      public int UserProducts_Id { get; set; }
      public int Count { get; set; }
      public System.DateTime DateCreated { get; set; }
      public virtual Product Product { get; set; }
      public virtual UserProducts UserProducts { get; set; }
  }
  
  [Table("dbo.Product")]
  public class Product
  {
      [Key]
      public int ProductID { get; set; }
      public int ProductTypeID { get; set; }
      public string Name { get; set; }
      public string SKU { get; set; }
      public string Description { get; set; }
      public string SpecTitle { get; set; }
      public decimal Price { get; set; }
      //public Int16 Published { get; set; }
      public bool Deleted { get; set; }
  
      public int SiteId { get; set; }
      public int UserId { get; set; }
  
  }
  
  
  [Table("dbo.UserProducts")]
  public class UserProducts
  {
      [Key]
      public int Id { get; set; }
      public string Name { get; set; }
      public int ArtworkId { get; set; }
      public int ProductId { get; set; }
      public decimal ProductPrice { get; set; }
      public string ProductDescription { get; set; }
      public string CreatedBy { get; set; }
      public DateTime CreatedOn { get; set; }
      public string ModifiedBy { get; set; }
      public DateTime? ModifiedOn { get; set; }
      public bool IsActive { get; set; }
      public string ArtworkPath { get; set; }
      public int UserId { get; set; }
      public int SiteId { get; set; }
  }
  </code></pre>
  
  <p>Problem is, that Product object is loaded when I load the cart from database. But the UserProducts object does not load and remains null. Following is the call. I also tried .Include(p => p.UserProducts), but it wont work also.</p>
  
  <pre><code>storeDB.Carts.Where(
              cart =&gt; cart.CartId == ShoppingCartId).ToList();
  </code></pre>
  
  <p>Is this has something to do with the Id naming convention of EF? bcz Product class has PK as ProductId, and in Cart class the FK for it is also named ProductId. But for UserProducts, that calss has PK named Id only, while in Cart class FK is named UserProducts_Id?</p>