using (var context = new BloggingContext()) { using (var transaction = context.Database.BeginTransaction()) { context.Blogs.Add(new Blog {Url = "http://www.zyiz.net/xilie-293.html"}); context.SaveChanges(); context.Blogs.Add(new Blog {Url = "http://www.zyiz.net/"}); context.SaveChanges(); transaction.Commit(); } }
比较简单,记录下,以备不时只需。