DbSet<TEntity>.Remove(TEntity) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Marks the given entity as Deleted such that it will be deleted from the database when SaveChanges is called. Note that the entity must exist in the context in some other state before this method is called.
public virtual TEntity Remove (TEntity entity);
abstract member Remove : 'Entity -> 'Entity
override this.Remove : 'Entity -> 'Entity
Public Overridable Function Remove (entity As TEntity) As TEntity
Parameters
- entity
- TEntity
The entity to remove.
Returns
The entity.
Implements
Remarks
Note that if the entity exists in the context in the Added state, then this method will cause it to be detached from the context. This is because an Added entity is assumed not to exist in the database such that trying to delete it does not make sense.
Applies to
Entity Framework