public virtual void Delete(FileLink entityToDelete) { entityToDelete.Delete(); if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } }