I am using EF4.1 to delete an object from my db:
public virtual void Delete(T entity)
{
_entities.CreateObjectSet<T>().DeleteObject(entity);
}
getting an error:
The object cannot be deleted because it was not found in the ObjectStateManager
I am using EF4.1 to delete an object from my db:
public virtual void Delete(T entity)
{
_entities.CreateObjectSet<T>().DeleteObject(entity);
}
getting an error:
The object cannot be deleted because it was not found in the ObjectStateManager
You get this error if the object you are trying to delete isnt attached to the current context. To get attached objects you either need to query the object from the db on the context, or manually call attach (before delete) to put the object onto the context.