EF对事务进行了封装:context的saveChange()是有事务性的
添加对System.Transactions的引用,调用TransactionScope类
dbContext.SaveChanges() 向数据库发出指令(sql)
必须保存修改,才会改变数据库数据
User entity = new User(); //新值
using (TravelMobileDataBaseEntities DbManager = new TravelMobileDataBaseEntities())
{
DbManager.Entry<User>(entity).State = EntityState.Modified; //修改
int count= DbManager.SaveChanges(); //执行
}
参考:http://www.cnblogs.com/riskyer/archive/2013/08/25/3281237.html