title: Remove row from db with EF Code First
body: <p>I try to use the following function to remove a item:</p>
  
  <pre><code>        internal static bool Remove(T record)
          {
  
              int result = 0;
  
              // get db set
              DatabaseDbContext context = new DatabaseDbContext();
              DbSet&lt;T&gt; set = context.Set&lt;T&gt;();
  
              // remove item
              set.Remove(record);
  
              // clean up
              context.Dispose();
              record.Dispose();
  
              // return result 
              return result &gt; 0;
          }
  </code></pre>
  
  <p>I get the error: "The object cannot be deleted because it was not found in the ObjectStateManager."</p>
  
  <p>How can I modify this to work like I want? </p>