//数据库事务开始 using (System.Data.Entity.DbContextTransaction trans = DbContext.Database.BeginTransaction()) { try { //数据库事务提交 trans.Commit(); } catch (Exception ex) { //数据库事务回滚 trans.Rollback(); } }