title: how read 2 table data having one to many relation form SQL in Entity Framework
body: <p>i am new  in  ASP.NET  its  my first  application in ASP.NET MVC how to  get data of product and  category in Product Object
  please check my controller. </p>
  
  <p>Category Class</p>
  
  <pre><code> public partial class Category
      {
          public Category()
          {
              Products = new HashSet&lt;Product&gt;();
          }
          public int categoryId { get; set; }
  
          [StringLength(50)]
          public string categoryTitle { get; set; }
  
          public int? categoryIndex { get; set; }           
  
          public virtual ICollection&lt;Product&gt; Products { get; set; }
      }
  </code></pre>
  
  <p>Product Class</p>
  
  <pre><code>public partial class Product
      {
          public int Id { get; set; }
  
          public int categoryId { get; set; }
  
          [StringLength(50)]
          public string productTitle { get; set; }
  
          [UIHint("tinymce_jquery_full"),  AllowHtml ]
          public string productDescription { get; set; }
  
          [StringLength(1)]
          public string status { get; set; }
  
        public virtual Category Category { get; set; }
      }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>public ActionResult Index()
          {
               DataContext db = new DataContext();
                // var products = db.Products.Where(a =&gt;a.productImage !=   // here is some code for getting list of products with category details  ) 
                // want to save value in product so that i can read like this 
  
                // products.productTitle;
                // products.productDescription ;
                // products.Category.categoryId ;
                // products.Category.categoryTitle ;
  
              return View(products);
          }
  </code></pre>
  
  <p>its  easy to get all product data  in "var product" variable but i need  all producta with  category id and category name like this products.Category.categoryTitle ; </p>
  
  <p>i am using  "code first from database" approach.</p>