public async Task<IActionResult> Index()
{
//TransactionScope sc = new TransactionScope() // 不用ef 的时候执行的事务处理
//using (TransactionScope sc = new TransactionScope())
//{
// try
// {
// _context.Book.Add(new Book { Name = "AAAAA", Content = "呢绒" });
// _context.SaveChanges();
// sc.Complete();//放在catch上面,否则不能回滚
// }
// catch (Exception)
// {
// }
//}
//return View(await _context.Book.ToListAsync());
using (var tran = _context.Database.BeginTransaction())
{
//efcore中的事物
try