Public ActionResult BackupDatabase() { var dbPath = Server.MapPath("~/App_Data/DBBackup.bak"); using (var db = new ProjectDbContext()) { var cmd = String.Format("BACKUP DATABASE {0} TO DISK='{1}' WITH FORMAT, MEDIANAME='DbBackups', MEDIADESCRIPTION='Media set for {0} database';" , "YourDB", dbPath); db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, cmd); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)