Example #1
0
        public void ClearDatabase()
        {
            foreach (var fruit in _context.FruitCategories)
            {
                _context.Remove(fruit);
            }

            foreach (var fruit in _context.Fruits)
            {
                _context.Remove(fruit);
            }
        }
        internal void ClearDatabase()
        {
            foreach (var fruit in _context.Fruits)
            {
                _context.Remove(fruit);
            }
            foreach (var category in _context.FruitCategories)
            {
                _context.Remove(category);
            }

            _context.SaveChanges();
        }
Example #3
0
        public void ClearDatabase()
        {
            foreach (var category in _context.FruitCategories)
            {
                _context.Remove(category);
            }

            foreach (var fruit in _context.Fruits)
            {
                _context.Remove(fruit);
            }

            // Alternativt: _context.RemoveRange(_context.Fruits);

            _context.SaveChanges();
        }