title: Adding new members to a DbSet<Class> in ASP.NET MVC 4
body: <p>Here is my scenario: I have a class called <strong>Order</strong>, which consists of basic information that should be saved in the database after that an order has been made.</p>
  
  <p>In <strong>MyPoject.Infrastructure</strong> I use following code:</p>
  
  <pre><code>public class ProductDb : DbContext, IProductDataSource
  {
  
      public ProductDb()
          : base("DefaultConnection")
      {
      }
  
  
      public DbSet&lt;Order&gt; Orders { get; set; }
  
  
      IQueryable&lt;Order&gt; IProductDataSource.Orders
      {
          get
          {
              return Orders;
          }
          set
          {
              Orders = (DbSet&lt;Order&gt;)value;
          }
      }
  }
  </code></pre>
  
  <p>In the <strong>Controller</strong>, I add this:</p>
  
  <pre><code>    private IProductDataSource _db = new ProductDb();
  
      public UserController(IProductDataSource db)
      {
          _db = db;
      }
  </code></pre>
  
  <p>Later on, in the <strong>ActionResult</strong>, where I want to add data to the order I use following:</p>
  
  <pre><code>var orders = _db.Orders;
  var order = new Order();
  
  //add some data to the order variable
  
  _db.Orders.AsEnumerable().Concat(new[] { order });
  _db.Save();
  </code></pre>
  
  <p>However, this does not appear to work. The problem I face is how it is possible to add new items to <strong>Order</strong> in the database.</p>
  
  <p>EDIT:
  <strong>IProductDataSource</strong> contains following code</p>
  
  <pre><code>    public interface IProductDataSource
  {
  
      IQueryable&lt;UserProfile&gt; UserProfiles { get; set; }
  
      IQueryable&lt;Order&gt; Orders { get; set; }
  
  
      void Save();
      void Add();
      //void Add();
  }
  </code></pre>