Ejemplo n.º 1
0
 public void DeleteTest()
 {
     using (AdventureWorks2014DbContext dbContext = new AdventureWorks2014DbContext())
     {
         using (System.Data.Entity.DbContextTransaction tran = dbContext.Database.BeginTransaction())
         {
             try
             {
                 Address _fined = dbContext.Find <Address>(22);
                 dbContext.Delete <Address>(_fined);
                 _fined = dbContext.Find <Address>(22);
                 Assert.IsNull(_fined);
                 dbContext.SaveChanges();
                 tran.Commit();
             }
             catch (Exception)
             {
                 tran.Rollback();
             }
         }
     }
 }