title: Equivalent of ObjectContext.AddObject(entityName, entity) on DbContext
body: <p>I upgraded an old project started in <code>ef4</code> but now I migrated it to <code>ef5</code>.</p>
  
  <p>This is the old code: </p>
  
  <pre><code>protected void SaveEntity&lt;T&gt;(T entity)
  {
          using (DocsManagerContainer context = new DocsManagerContainer())  
                  {  
                      string entityType = typeof(T).ToString();  
                      GetLogger().LogMessage("Save " + entityType + " started", LogLevel.Info);  
                      DbTransaction transaction = null;  
                      try  
                      {  
                          context.Connection.Open();  
                          transaction = context.Connection.BeginTransaction();  
                          context.AddObject(typeof(T).Name + "s", entity);  
                          transaction.Commit();  
                          context.SaveChanges();  
                      }  
                      catch (Exception e)  
                      {  
                          GetLogger().LogMessage("Save " + entityType + " thrown error :", e, LogLevel.Error);  
                          throw e;  
                      }  
                      finally  
                      {  
                          context.Connection.Close();  
                          transaction = null;  
                      }  
                      GetLogger().LogMessage("Save " + entityType + " ended", LogLevel.Info);  
                  }  
      }
  </code></pre>
  
  <p>I've upgraded almost all of the code except : <code>context.AddObject(typeof(T).Name + "s", entity);</code>, but this isn't supported anymore.<br>
  How can I upgrade this ?</p>
  
  <p>p.s. I do want to use generic code, not to use switches to add the corresponding object to correct <code>ObjectSet</code>
  p.s. Error if I use .Set().Add(entity) is : </p>
  
  <pre><code>Error   2   The type 'T' must be a reference type in order to use it as parameter 'TEntity' in the generic type or method 'System.Data.Entity.DbContext.Set&lt;TEntity&gt;()' D:\work\DocsManager\trunk\DocsManagerDataMapper\EF4Factory\BaseEF4Factory.cs    64  21  DocsManagerDataMapper
  </code></pre>