IDbSet<TEntity>.Remove Method

[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]

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.

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

Syntax

'Declaration
Function Remove ( _
    entity As TEntity _
) As TEntity
'Usage
Dim instance As IDbSet 
Dim entity As TEntity
Dim returnValue As TEntity

returnValue = instance.Remove(entity)
TEntity Remove(
    TEntity entity
)
TEntity Remove(
    TEntity entity
)
abstract Remove : 
        entity:'TEntity -> 'TEntity 
function Remove(
    entity : TEntity
) : TEntity

Parameters

  • entity
    Type: TEntity
    The entity to remove.

Return Value

Type: TEntity
The entity.

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.

See Also

Reference

IDbSet<TEntity> Interface

System.Data.Entity Namespace