Try our conversational search powered by Generative AI!

An unhandled exception occurred while processing the request.

Vote:
 

I just installed a sample site using the command

dotnet new epi-alloy-mvc

And I run it as localhost. But when I try to login inside the webpage, I keep getting this error no matter what credentials I use:

An unhandled exception occurred while processing the request.
InvalidOperationException: Sequence contains more than one matching element
System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()

TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Query.QueryableMethods' threw an exception.
Microsoft.EntityFrameworkCore.Query.QueryableMethods.get_FirstOrDefaultWithPredicate()

System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
   at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.EntityFrameworkCore.Query.QueryableMethods..cctor()

TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Query.QueryableMethods' threw an exception.
Microsoft.EntityFrameworkCore.Query.QueryableMethods.get_FirstOrDefaultWithPredicate()
Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.FirstOrDefaultAsync<TSource>(IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<TUser, TRole, TContext, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim>.FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
Microsoft.AspNetCore.Identity.UserManager<TUser>.FindByNameAsync(string userName)
EPiServer.Cms.UI.AspNetIdentity.ApplicationSignInManager<TUser>.SignInAsync(string userName, string password, string returnUrl)
EPiServer.Cms.UI.AspNetIdentity.ApplicationUISignInManager<TUser>.SignInAsync(string userName, string password)
EPiServer.Cms.Shell.UI.Controllers.Internal.AccountController.ExecuteLogin(LoginViewModel model)
Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask<IActionResult> actionResultValueTask)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

What are the credentials I should use here?

#278786
Apr 20, 2022 8:03
Vote:
 

Hi, this is probably due to not running correct version of Entity Framework. See https://world.optimizely.com/blogs/Magnus-Rahl/Dates/2022/3/resolving-nuget-dependency-conflicts-in-project-sdk-packagereference-model/. Did you upgrade to .NET6? Either explicitly reference the correct versions, or upgrade to latest EPiServer.CMS package that is cross-compiled for both .NET5 and 6. 

#278788
Apr 20, 2022 9:29
Vote:
 


The .NET version is:

> dotnet --version
6.0.202

And the Target framework is .NET 6.0. Where from do I download the EPiServer.CMS package?


#278792
Apr 20, 2022 12:25
Vote:
 

The SDK/tool version is one thing. But you have probably changed the project to compile to .NET6? That requires you to also update the dependencies to use their .NET6 equivalents. You probably only have to change from:

<PackageReference Include="EPiServer.CMS" Version="12.3.1" />

To:

<PackageReference Include="EPiServer.CMS" Version="12.5.0" />

In your project file and re-build. Here is the feed https://nuget.optimizely.com/feed/packages.svc/, but it's probably already configured in your nuget.config in the project? You should not download the packages manually, let dotnet/nuget handle those for you.

#278796
Apr 20, 2022 12:46
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.