public void DeleteSamuraiGraph(int id)
        {
            //goal: delete samurai, quotes, secret identity and any joins with battles
            //EF Core support Cascade Delete by convention
            //Even if full Graph is not in memory, db is defined to delete
            //But always doble check
            var samurai = _context.Samurais.Find(id); //NoTracking

            _context.Entry(samurai).State = EntityState.Deleted;
            _context.SaveChanges();
        }
Beispiel #2
0
        public void DeleteSamuraiGraph(int id)
        {
            //goal:  delete samurai , quotes and secret identity
            //       also delete any joins with battles
            //EF Core supports Cascade delete by convention
            //Even if full graph is not in memory, db is defined to delete
            //But always double check!
            var samurai = _context.Samurais.Find(id);            //NOT TRACKING !!

            _context.Entry(samurai).State = EntityState.Deleted; //TRACKING
            _context.SaveChanges();
        }