使用EF6你有新的事务处理可以使用类似于: 复制代码 using (var context = new PostEntityContainer()) { using (var dbcxtransaction = context.Database.BeginTransaction()) { try { PostInformation NewPost = new PostInformation() { PostId = 101, Content = "This is my first Post re…
在使用Entity Framework为主从表添加数据,当一个表添加数据成功,另一个表添加数据失败,这时候就需要用到事务回滚. 比如有以下关系的2张表. 客户端使用TransactionScope类可以实现事务回滚. class Program { static void Main(string[] args) { try { using (TransactionScope ts = new TransactionScope()) { using (CountryDetailsEntities…
ASP.NET Entity FrameWork中: int flag = -1; if (this.URPmanagementEntities1.Connection.State != System.Data.ConnectionState.Open) { this.URPmanagementEntities1.Connection.Open(); } var trans = this.URPmanagementEntities1.Connection.BeginTransaction();…