static void listRabbits() { using (var db = new RabbitDbContext()) { rabbits = db.Rabbits.ToList(); } rabbits.ForEach(r => Console.WriteLine($"{r.RabbitId,-10}{r.RabbitName,-20}{r.Age}")); }
static void updateRabbit() { using (var db = new RabbitDbContext()) { var rabbitToUpdate = db.Rabbits.Find(3); rabbitToUpdate.RabbitName = "Rabbit3 has a new name"; db.SaveChanges(); } }
static void addRabbit() { using (var db = new RabbitDbContext()) { var rabbit = new Rabbit(3, "Rabbit3", 0); //add to database db.Rabbits.Add(rabbit); db.SaveChanges(); } }