public async Task SeedData() { var seedUserEmail = _config["SeedUser:Email"]; var seedUser = await _db.Users.IgnoreQueryFilters().FirstOrDefaultAsync(user => user.Email == seedUserEmail); if (seedUser == null) { _logger.LogInformation($"Seeding Database..."); _logger.LogInformation($"Creating User..."); var user = new User { FullName = "John Smith", Address = "1099 King Street", City = "Auckland", Country = "New Zealand", PostCode = "1024", DateOfBirth = DateTime.UtcNow.AddYears(-30), Email = seedUserEmail, Phone = "+642112345678", CreatedOn = DateTime.UtcNow }; await _db.Users.AddAsync(user); await _db.SaveChangesAsync(); _tenantProvider.SetTenantId(user.Id); _logger.LogInformation($"Creating Accounts..."); var account1 = await _accountService.OpenAccount( new OpenAccountRequest { AccountType = AccountType.TRANSACTION }, user.Id); var account2 = await _accountService.OpenAccount( new OpenAccountRequest { AccountType = AccountType.SAVING }, user.Id); await _db.SaveChangesAsync(); _logger.LogInformation($"Seeding Transactions..."); var transactions = ReadFromFile(); foreach (var transaction in transactions) { account1.PostTransaction(transaction); } _db.Update(account1); await _db.SaveChangesAsync(); } else { _logger.LogInformation($"Seed User {seedUserEmail} Already Exists..."); } }