public void DropTables() { using (var dropTablesContext = new PasswordsDbContext()) { IList <Password> passwordList = new List <Password>(); foreach (var entry in dropTablesContext.Passwords) { passwordList.Add(entry); } dropTablesContext.Passwords.RemoveRange(passwordList); dropTablesContext.SaveChanges(); } }
public void writeToFile(string passName, string userName, string pass) { var nameToWrite = passName; var userNametoWrite = userName; var passToWrite = pass; Random randomNumber = new Random(); using (var dbPasswordContext = new PasswordsDbContext()) { var userNamePassword = new Password() { Name = nameToWrite, UserName = userNametoWrite, NewPass = passToWrite }; dbPasswordContext.Passwords.Add(userNamePassword); dbPasswordContext.SaveChanges(); } }