I am using EF6 and I am trying to delete an entity like this:

```
  public virtual void Delete(TEntity entity)
    {

        DbContext.Configuration.ValidateOnSaveEnabled = false;
        DbContext.ChangeTracker.DetectChanges();

        _dbSet.Remove(entity);
    }

```

But it's giving me error like this:

[![enter image description here](https://i.stack.imgur.com/Tb4km.png)](https://i.stack.imgur.com/Tb4km.png)

Then I used another method like this:

```
    DbContext.ChangeTracker.DetectChanges();
        DbContext.Entry(entity).State = EntityState.Deleted;

```

and now the error is something like:
[![enter image description here](https://i.stack.imgur.com/TXNl9.png)](https://i.stack.imgur.com/TXNl9.png)

Thanks in advance.