Issue #3014950 by goodboy, mondrake, alexpott: Replace all db calls to file_managed table with Entity APIs