public void SetUp() { var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json"); _configuration = builder.Build(); _optionsReq = new DbContextOptionsBuilder <RequirementsContext>().UseLazyLoadingProxies().UseSqlServer(_configuration.GetConnectionString("RequirementsContext")).Options; _optionsUser = new DbContextOptionsBuilder <UsersContext>().UseLazyLoadingProxies().UseSqlServer(_configuration.GetConnectionString("UsersContext")).Options; _reqContext = new RequirementsContext(_optionsReq); _usersContext = new UsersContext(_optionsUser); _service = new ScheduleService(_reqContext, _usersContext); if (needReset) { SeedUsersData.reset = true; SeedRequirementsData.reset = true; needReset = false; } else { SeedUsersData.reset = false; SeedRequirementsData.reset = false; } SeedRequirementsData.Initialize(_reqContext); SeedUsersData.Initialize(_usersContext); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { RequirementsContext requirementsContext = new RequirementsContext(services.GetRequiredService <DbContextOptions <RequirementsContext> >()); UsersContext usersContext = new UsersContext(services.GetRequiredService <DbContextOptions <UsersContext> >()); AccountsContext accountsContext = new AccountsContext(services.GetRequiredService <DbContextOptions <AccountsContext> >()); SeedRequirementsData.Initialize(requirementsContext); SeedUsersData.Initialize(usersContext); SeedDataAccountsDb.Initialize(accountsContext); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occured seeding the DB."); } } host.Run(); }
public ProfileController(UsersContext context, IScheduleService service, RequirementsContext reqContext) { _context = context; _service = service; _reqContext = reqContext; }
//Intialize a DatabaseContext and open a DB connection static DatabaseManager() { _context = new RequirementsContext(); }
public ScheduleService(RequirementsContext requirementsContext, UsersContext usersContext) { _reqContext = requirementsContext; _usersContext = usersContext; }
public ModifyRequirementsController(RequirementsContext requirements, UsersContext users) { _requirementsContext = requirements; _usersContext = users; }