Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

There is no such an entity exception when updating user #3276


User avatar
0
OutdoorEd created

Hello all,

I've activated email verification when creating a new user today, but I've faced the below exception when the user clicks on the link sent in the activation email. It fails when on the line

await _userManager.UpdateAsync(user);

and the exception detail is "Abp.Domain.Entities.EntityNotFoundException: There is no such an entity. Entity type: XYZ.Authorization.Users.User, id: 5"

I've double checked that there is user id: 5 in the DB so I'm not sure why this is failing now?

Any insights will be appreciated.

Exception detail as the below:

There is no such an entity. Entity type: XYZ.Authorization.Users.User, id: 5

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: Abp.Domain.Entities.EntityNotFoundException: There is no such an entity. Entity type: XYZ.Authorization.Users.User, id: 5

Source Error: 


Line 672:            user.EmailConfirmationCode = null;
Line 673:
Line 674:            await _userManager.UpdateAsync(user);
Line 675:
Line 676:            var tenancyName = user.TenantId.HasValue


Stack Trace: 


[EntityNotFoundException: There is no such an entity. Entity type: XYZ.Authorization.Users.User, id: 5]
   Abp.Domain.Repositories.<GetAsync>d__17.MoveNext() in D:\Halil\Github\aspnetboilerplate\src\Abp\Domain\Repositories\AbpRepositoryBase.cs:86
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   Abp.Threading.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__5`1.MoveNext() in D:\Halil\Github\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs:120
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   Abp.Authorization.Users.&lt;GetUserNameFromDatabaseAsync&gt;d__64.MoveNext() in D:\Halil\Github\module-zero\src\Abp.Zero\Authorization\Users\AbpUserStore.cs:0
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   Abp.Authorization.Users.&lt;UpdateAsync&gt;d__41.MoveNext() in D:\Halil\Github\module-zero\src\Abp.Zero\Authorization\Users\AbpUserManager.cs:343
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +28
   XYZ.Web.Controllers.<EmailConfirmation>d__39.MoveNext() in C:\Repos\Personal\XYZ_MVC\XYZ.Web\Controllers\AccountController.cs:674
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   Abp.Threading.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__5`1.MoveNext() in D:\Halil\Github\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs:120
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +97
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass37.&lt;BeginInvokeAsynchronousActionMethod&gt;b__36(IAsyncResult asyncResult) +17
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.AsyncInvocationWithFilters.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3d() +50
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass46.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3f() +225
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass46.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3f() +225
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass46.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3f() +225
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass46.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3f() +225
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass33.&lt;BeginInvokeActionMethodWithFilters&gt;b__32(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass2b.&lt;BeginInvokeAction&gt;b__1c() +26
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass21.&lt;BeginInvokeAction&gt;b__1e(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.Controller.&lt;BeginExecuteCore&gt;b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
   Castle.Proxies.AccountControllerProxy.EndExecuteCore_callback(IAsyncResult asyncResult) +4
   Castle.Proxies.Invocations.Controller_EndExecuteCore.InvokeMethodOnTarget() +55
   Castle.DynamicProxy.AbstractInvocation.Proceed() +80
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) in D:\Halil\Github\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:29
   Castle.DynamicProxy.AbstractInvocation.Proceed() +108
   Castle.Proxies.AccountControllerProxy.EndExecuteCore(IAsyncResult asyncResult) +142
   System.Web.Mvc.Controller.&lt;BeginExecute&gt;b__15(IAsyncResult asyncResult, Controller controller) +12
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   Castle.Proxies.AccountControllerProxy.EndExecute_callback(IAsyncResult asyncResult) +26
   Castle.Proxies.Invocations.Controller_EndExecute.InvokeMethodOnTarget() +55
   Castle.DynamicProxy.AbstractInvocation.Proceed() +80
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) in D:\Halil\Github\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:29
   Castle.DynamicProxy.AbstractInvocation.Proceed() +108
   Castle.Proxies.AccountControllerProxy.EndExecute(IAsyncResult asyncResult) +142
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.MvcHandler.&lt;BeginProcessRequest&gt;b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129

3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ OutdoorEd,

    Can you check if email verification link contains tenantId or not ? As I remember there was a similar bug and we fixed it.

    Thanks.

  • User Avatar
    0
    OutdoorEd created

    This was an email verification for a host account, so most probably it doesn't contain a tenant id.

    Here is the link: <a class="postlink" href="http://localhost:6240/Account/EmailConfirmation?userId=UOLEwSlB48CbDaGRVjAsWA%3D%3D&">http://localhost:6240/Account/EmailConf ... sWA%3D%3D&</a>**tenantId=&**confirmationCode=334064c4ba6c40759eb95e6d463f2c57

    Looking at the tenantid query string param, it is empty. How can we fix this?

    Here are the version of packages we are using:

    <package id="Abp" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.AutoMapper" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.Castle.Log4Net" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.EntityFramework" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.EntityFramework.Common" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.HangFire" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.Owin" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.RedisCache" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.Web" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.Web.Api" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.Web.Common" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.Web.Mvc" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.Web.Resources" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.Web.SignalR" version="1.2.1.0" targetFramework="net461" />
      <package id="Abp.Zero" version="1.2.0.0" targetFramework="net461" />
      <package id="Abp.Zero.EntityFramework" version="1.2.0.0" targetFramework="net461" />
      <package id="Abp.Zero.Ldap" version="1.2.0.0" targetFramework="net461" />
      <package id="Abp.Zero.Owin" version="1.2.0.0" targetFramework="net461" />
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I couldn't find the related issue on AspNet Zero repository but can you compare your EmailConfirmation method with the latest version <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/blob/master/src/MyCompanyName.AbpZeroTemplate.Web/Controllers/AccountController.cs#L655">https://github.com/aspnetzero/aspnet-ze ... er.cs#L655</a> ?

    Thanks.