protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); try { new AppDbContext().CreateDB(); var candidateRepository = new CandidateRepository(); if (candidateRepository.IsAnyCandidate()) { return; } var candidateJsonData = new CandidateJsonData().GetAll(); if (candidateJsonData != null) { candidateRepository.AddAll(candidateJsonData); } else { Current.Shutdown(); } } catch (Exception exception) { ErrorMessage.ShowError($"Can not connect to database.\n", exception); Current.Shutdown(); } }