public void EnsureDatabaseCreation() { using (var context = new ContactManagerDbContext(_contextOptions)) { if (context.Database.EnsureCreated()) { var randomContactGenerator = new RandomContactGenerator(); var contacts = randomContactGenerator.GenerateContacts(5000); context.Contacts.AddRange(contacts); context.SaveChanges(); } } }
public Contact CreateContact(Contact contact) { _context.Contacts.Add(contact); _context.SaveChanges(); return(contact); }