public void Remove(User user) { using (var _dbContext = new IdentityManagementEntities()) { _dbContext.Users.Attach(user); _dbContext.Entry(user).State = System.Data.EntityState.Deleted; _dbContext.SaveChanges(); } }
public void Update(User user) { //save modified entity using new Context using (var _dbContext = new IdentityManagementEntities()) { _dbContext.Users.Attach(user); _dbContext.Entry(user).State = System.Data.EntityState.Modified; _dbContext.SaveChanges(); } }
public void Add(User user) { //Add to Database try { using (var _dbContext = new IdentityManagementEntities()) { _dbContext.Users.Add(user); //_dbContext.Entry(user).State = System.Data.EntityState.Added; _dbContext.SaveChanges(); } } catch (Exception ex) { } }