public async Task LogAsync(Exception exception) { var id = Guid.NewGuid(); var now = DateTimeOffset.Now; int ordinal = 0; for (var e = exception; e != null; e = e.InnerException) { var log = ExceptionLog.FromException(e, id, ordinal++, now); await ExceptionLogs.AddAsync(log); } await SaveChangesAsync(); }