Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

InvalidOperationException: Sequence contains more than one element

Boa Tarde! Como Resolver está exception? An unhandled exception occurred while processing the request. InvalidOperationException: Sequence contains more than one element System.Linq.Enumerable.SingleOrDefault(IEnumerable source)

Stack Query Cookies Headers InvalidOperationException: Sequence contains more than one element System.Linq.Enumerable.SingleOrDefault(IEnumerable source) System.Linq.Queryable.SingleOrDefault(IQueryable source) CasaDoCodigo.Rpositories.PedidoRepository.AddItem(string codigo) in PedidoRepository.cs + var produto = contexto.Set() CasaDoCodigo.Controllers.PedidoController.Carrinho(string codigo) in PedidoController.cs + pedidoRepository.AddItem(codigo); lambda_method(Closure , object , Object[] ) Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, Object[] parameters) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__12.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__10.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__14.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__22.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__17.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__15.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Builder.RouterMiddleware+d__4.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Session.SessionMiddleware+d__9.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Session.SessionMiddleware+d__9.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+d__7.MoveNext()

1 resposta
solução!

Oi Kaique, aconteceu comigo também e com outra pessoa que postou a mesma dúvida no fórum. Se você apagar seu banco de dados e executar o seu programa novamente este erro para de aparecer, ele meio que tenta recriar os dados ja existentes no seu banco de dados.

Espero que ajude ;-)