public void InitContext() { var builder = new DbContextOptionsBuilder <SQLiteLogQuakeContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database"); _context = new SQLiteLogQuakeContext(builder.Options); IMemoryCache cache = new MemoryCache(new MemoryCacheOptions()); LoggerFactory loggerFactoryServices = new LoggerFactory(); loggerFactoryServices.AddConsole(LogLevel.None); loggerFactoryServices.AddDebug(LogLevel.None); _loggerLogQuakeServices = new Logger <LogQuakeService>(loggerFactoryServices); _unitOfWork = new UnitOfWork(_context, cache, _configuration); _logQuakeService = new LogQuakeService(_unitOfWork, cache, _loggerLogQuakeServices, _configuration); LoggerFactory loggerFactory = new LoggerFactory(); loggerFactory.AddConsole(LogLevel.None); loggerFactory.AddDebug(LogLevel.None); _loggerGamesController = new Logger <GamesController>(loggerFactory); _configuration = new ConfigurationBuilder() .SetBasePath(System.AppContext.BaseDirectory) .AddJsonFile("appsettings.json") .Build(); }
public void InitContext() { var builder = new DbContextOptionsBuilder <SQLiteLogQuakeContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database"); _context = new SQLiteLogQuakeContext(builder.Options); IMemoryCache cache = new MemoryCache(new MemoryCacheOptions()); _killRepository = new KillRepository(_context, cache, _configuration); _configuration = new ConfigurationBuilder() .SetBasePath(System.AppContext.BaseDirectory) .AddJsonFile("appsettings.json") .Build(); }
public Startup(IConfiguration configuration, ILogger <Startup> logger) { Configuration = configuration; _logger = logger; string BancoDeDados = Configuration["DataBase"].ToString().ToUpper(); if (BancoDeDados == "SQLITE") { string stringConnection = this.Configuration.GetConnectionString("SQLiteConnectionString"); DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder <LogQuakeContext>(); optionsBuilder.UseSqlite(stringConnection); // Cria o Banco de Dados para SqLite using (var client = new SQLiteLogQuakeContext(optionsBuilder.Options)) { client.Database.EnsureCreated(); } } }
public void Cleanup() { _context.Database.EnsureDeleted(); _context.Dispose(); _context = null; }