예제 #1
0
        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();
            }
        }
예제 #2
0
        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);
        }