Steps
- Get the user – ideally you want to use the userid (or primary key) to retrieve the user
- Remove the user from the db
- 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