[Solved] asp net. How to remove data from a database


Steps

  1. Get the user – ideally you want to use the userid (or primary key) to retrieve the user
  2. Remove the user from the db
  3. Save the changes in the context

Code:

var user = db.Users.Single(x => x.Nom == formUser.Nom && x.prenom == formuser.prenom);
db.Users.Remove(user);
db.SaveChanges();

solved asp net. How to remove data from a database