Ejemplo n.º 1
0
        public static StoreDbContext Create()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            var options = new DbContextOptionsBuilder <StoreDbContext>()
                          // .UseInMemoryDatabase(Guid.NewGuid().ToString()) //Throws null reference exception when data doesn't exist,when it should return null
                          .UseSqlite(connection)
                          .Options;

            var operationalStoreOption = new OptionsManager <OperationalStoreOptions>(new OperationalStoreOptionsFactory());

            var context = new StoreDbContext(options, operationalStoreOption);

            context.Database.EnsureCreated();

            TestStoreDBInitializer.Initialize(context);

            return(context);
        }
Ejemplo n.º 2
0
        public static void Initialize(StoreDbContext context)
        {
            var initializer = new TestStoreDBInitializer();

            initializer.SeedEverything(context);
        }