public PeopleControllerTests() { DbContextOptionsBuilder <PeopleDBContext> options = new DbContextOptionsBuilder <PeopleDBContext>(); options.UseInMemoryDatabase("Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory;Trusted_Connection=True;ConnectRetryCount=0"); context = new PeopleDBContext(options.Options); if (context.People.ToList().Count == 0) { PeopleDBInitializer peopleDBInitializer = new PeopleDBInitializer(context); peopleDBInitializer.SeedDBContext(); } }
private void ConfigureInMemoryDBContext(IServiceCollection services) { DbContextOptionsBuilder <PeopleDBContext> options = new DbContextOptionsBuilder <PeopleDBContext>(); options.UseInMemoryDatabase(Configuration.GetConnectionString("DevConnection")); PeopleDBContext context = new PeopleDBContext(options.Options); var peopleDbInitializer = new PeopleDBInitializer(context); peopleDbInitializer.SeedDBContext(); services.AddSingleton(context); }