static void addRabbit() { using (var db = new RabbitDbContext()) { var rabbit = new Rabbit(3, "Rabbit3", 0); // add to database db.Rabbits.Add(rabbit); db.SaveChanges(); } }
static Rabbit NewRabbit() { var rn = new PersonNameGenerator(); Rabbit r = new Rabbit() { RabbitName = rn.GenerateRandomFirstName(), RabbitAge = 0 }; return(r); }
static void addRabbit(DbContext db) { foreach (Rabbit i in rabbits) { if (i.RabbitAge > 2) { Rabbit r = NewRabbit(); db.Add(r); } } db.SaveChanges(); }