title: Adding Object in Entity Framework
body: <p>In an Application it has Data Access layer.In which it has DataEntityModel.edmx  (entityframework model)  and repository class.</p>
  
  <p><a href="https://i.stack.imgur.com/WZY54.png" rel="nofollow"><img src="https://i.stack.imgur.com/WZY54.png" alt="enter image description here"></a></p>
  
  <p>Below code is my repository class.</p>
  
  <pre><code>namespace DataModel.Repository
  {
   public class ProductRepository
   {
      internal WebApiDbEntities Context;
      internal DbSet&lt;Product&gt; DbSet;
  
       public ProductRepository(WebApiDbEntities context)
      {
          this.Context = context;
          this.DbSet = context.Set&lt;Product&gt;();
      }
  
      public virtual void Insert(Product entity)
      {
          DbSet.Add(entity);
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <blockquote>
    <p>Question is I have used <strong>DbSet.Add(entity)</strong> method to insert . But Entity Framework will generate it's own Add method <strong>Context.Products.Add(entity)</strong></p>
    
    <p>So, What is the difference between those two methods. Why Most of the
    time <strong>DbSet.Add(entity)</strong> is used ??</p>
  </blockquote>