I have an error screen when I want to see Order details in Admin Panel and 500 error in console of browser on the page of all Orders - js try to fetch some data of Orders but it failed. After rebooting app it is gone. But the problem happen every day. There is log of nopcommerce app
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (4ms) [Parameters=[@__get_Item_0='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30']
SELECT TOP(1) [e].[Id], [e].[AffiliateId], [e].[AllowStoringCreditCardNumber], [e].[AuthorizationTransactionCode], [e].[AuthorizationTransactionId], [e].[AuthorizationTransactionResult], [e].[BillingAddressId], [e].[CaptureTransactionId], [e].[CaptureTransactionResult], [e].[CardCvv2], [e].[CardExpirationMonth], [e].[CardExpirationYear], [e].[CardName], [e].[CardNumber], [e].[CardType], [e].[CheckoutAttributeDescription], [e].[CheckoutAttributesXml], [e].[CreatedOnUtc], [e].[CurrencyRate], [e].[CustomOrderNumber], [e].[CustomValuesXml], [e].[CustomerCurrencyCode], [e].[CustomerId], [e].[CustomerIp], [e].[CustomerLanguageId], [e].[CustomerTaxDisplayTypeId], [e].[Deleted], [e].[MaskedCreditCardNumber], [e].[OrderDiscount], [e].[OrderGuid], [e].[OrderShippingExclTax], [e].[OrderShippingInclTax], [e].[OrderStatusId], [e].[OrderSubTotalDiscountExclTax], [e].[OrderSubTotalDiscountInclTax], [e].[OrderSubtotalExclTax], [e].[OrderSubtotalInclTax], [e].[OrderTax], [e].[OrderTotal], [e].[PaidDateUtc], [e].[PaymentMethodAdditionalFeeExclTax], [e].[PaymentMethodAdditionalFeeInclTax], [e].[PaymentMethodSystemName], [e].[PaymentStatusId], [e].[PickupAddressId], [e].[PickupInStore], [e].[RefundedAmount], [e].[RewardPointsHistoryEntryId], [e].[ShippingAddressId], [e].[ShippingMethod], [e].[ShippingRateComputationMethodSystemName], [e].[ShippingStatusId], [e].[StoreId], [e].[SubscriptionTransactionId], [e].[TaxRates], [e].[VatNumber]
FROM [Order] AS [e]
WHERE [e].[Id] = @__get_Item_0
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.VisitChildren(ExpressionVisitor visitor)
at Microsoft.EntityFrameworkCore.SqlServer.Query.Sql.Internal.SqlServerQuerySqlGenerator.RowNumberPagingExpressionVisitor.VisitSelectExpression(SelectExpression selectExpression)
at Microsoft.EntityFrameworkCore.SqlServer.Query.Sql.Internal.SqlServerQuerySqlGeneratorFactory.CreateDefault(SelectExpression selectExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.GetRelationalCommand(IReadOnlyDictionary`2 parameters)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntities[TOut,TIn](IEnumerable`1 results, QueryContext queryContext, IList`1 entityTrackingInfos, IList`1 entityAccessors)+MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Nop.Services.Discounts.DiscountService.GetAllDiscountUsageHistory(Nullable`1 discountId, Nullable`1 customerId, Nullable`1 orderId, Int32 pageIndex, Int32 pageSize)
at Nop.Web.Areas.Admin.Factories.OrderModelFactory.PrepareOrderModelTotals(OrderModel model, Order order) in C:\andrei\nopcommerce\sources\src\Presentation\Nop.Web\Areas\Admin\Factories\OrderModelFactory.cs:line 457
at Nop.Web.Areas.Admin.Factories.OrderModelFactory.PrepareOrderModel(OrderModel model, Order order, Boolean excludeProperties) in C:\andrei\nopcommerce\sources\src\Presentation\Nop.Web\Areas\Admin\Factories\OrderModelFactory.cs:line 1072
at Nop.Web.Areas.Admin.Controllers.OrderController.Edit(Int32 id) in C:\andrei\nopcommerce\sources\src\Presentation\Nop.Web\Areas\Admin\Controllers\OrderController.cs:line 1099
at lambda_method(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at WebMarkupMin.AspNetCore2.WebMarkupMinMiddleware.Invoke(HttpContext context)
at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 94
at Nop.Services.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) in C:\andrei\nopcommerce\sources\src\Libraries\Nop.Services\Authentication\AuthenticationMiddleware.cs:line 79
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Nop.Services.Installation.InstallUrlMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in C:\andrei\nopcommerce\sources\src\Libraries\Nop.Services\Installation\InstallUrlMiddleware.cs:line 52
at Nop.Services.Common.KeepAliveMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in C:\andrei\nopcommerce\sources\src\Libraries\Nop.Services\Common\KeepAliveMiddleware.cs:line 49
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.<>c.<UseNopExceptionHandler>b__1_1(HttpContext context) in C:\andrei\nopcommerce\sources\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationBuilderExtensions.cs:line 89
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
Route matched with {action = "Error", controller = "Error", area = ""}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Error() on controller Nop.Web.Controllers.ErrorController (Nop.Web).
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
Executing action method Nop.Web.Controllers.ErrorController.Error (Nop.Web) - Validation state: Valid
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action method Nop.Web.Controllers.ErrorController.Error (Nop.Web), returned result Microsoft.AspNetCore.Mvc.VirtualFileResult in 0.0064ms.
info: Microsoft.AspNetCore.Mvc.Infrastructure.VirtualFileResultExecutor[1]
Executing Microsoft.AspNetCore.Mvc.VirtualFileResult, sending file 'errorpage.htm' with download name '' ...
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action Nop.Web.Controllers.ErrorController.Error (Nop.Web) in 1.1048ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 170.0124ms 500 text/html
NopCommerce 4.20
SQL SERVER 15.0.2000
windows server 2016
Help me to understand what the problem and how to fix it