public static int DeleteEntity<TEntity>(
this DbContext dataContext,
TEntity entity
)
<ExtensionAttribute>
Public Shared Function DeleteEntity(Of TEntity) (
dataContext As DbContext,
entity As TEntity
) As Integerpublic:
[ExtensionAttribute]
generic<typename TEntity>
static int DeleteEntity(
DbContext^ dataContext,
TEntity entity
)[<ExtensionAttribute>]
static member DeleteEntity :
dataContext : DbContext *
entity : 'TEntity -> int The stored procedure name is determined by looking for the DeleteEntityStoredProcedureAttribute on the entity type. The stored procedure must have one or more parameters representing the key columns on the entity type identified with a PrimaryKeyAttribute or one or more properties with a KeyAttribute or defined by the data context. It should not return a value or a result set. All parameters are input only.
If the connection is not in an open state, it is opened temporarily while deleting the entity. If change tracking is enabled on the data context and the entity its state will be set to unattached.
using var dataContext = new MyDbContext();
dataContext.DeleteEntity(watchListItem);