// CRUD - CREATE, READ, UPDATE, DELETE static void CreateNewUser() { using var context = new MyDatabaseContext(); var newUser = new User { Name = "Raja", Email = "*****@*****.**" }; context.Users.Add(newUser); context.SaveChanges(); }
static void UpdateUserEmail(int id, string email) { using var context = new MyDatabaseContext(); var user = context.Users.Find(id); if (user != null) { user.Email = email; } context.SaveChanges(); }