title: The object cannot be deleted because it was not found in the ObjectStateManager in entity framework 5
body: <p>I'm trying to delete an object using EntityFramework 5 but i get this error.
  <em>The object cannot be deleted because it was not found in the ObjectStateManager</em> <br/>
  I am using the <code>Remove()</code> method as <code>DeleteObject()</code> is not present in EF5.
  Can anyone help what am I missing?</p>
  
  <p>This does not work for Remove</p>
  
  <pre><code>localDb.Customers.Remove(new Customer() { CustomerId = id });
                  localDb.SaveChanges();
  </code></pre>
  
  <p>Another thing I tried from msdn to change the state to Deleted. But here it gives an error saying all the fields should be present. Is it necessary to get the complete record then delete?</p>
  
  <pre><code>var customer = new Customer(){ CustomerId = id };
                  localDb.Customers.Attach(customer);
  
                  localDb.Entry(customer).State = EntityState.Deleted;
                  localDb.SaveChanges();
  </code></pre>
  
  <p>Any inputs?</p>