Vacuum Sqlite database with EntityFramework 6.1
Try this to force EF to not use transaction because
A VACUUM will fail if there is an open transaction, or if there are one or more active SQL statements when it is run.
context.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "VACUUM;");