Base solution for your next web application
Open Closed

There is no such an entity with given primary key. Entity ty #1380


User avatar
0
sergii created

At very first run I have the exception, only HangFire tables have been created and DB locked after the exception raised

Server Error in '/' Application.

There is no such an entity with given primary key. Entity type: MyTest.MultiTenancy.Tenant, primary key: 1

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.AbpException: There is no such an entity with given primary key. Entity type: MyTest.MultiTenancy.Tenant, primary key: 1

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[AbpException: There is no such an entity with given primary key. Entity type: MyTest.MultiTenancy.Tenant, primary key: 1]
   Abp.Domain.Repositories.AbpRepositoryBase`2.Get(TPrimaryKey id) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Repositories\AbpRepositoryBase.cs:70
   Castle.Proxies.EfRepositoryBase`2Proxy_2.Get_callback(Int32 id) +5
   Castle.Proxies.Invocations.AbpRepositoryBase`2_Get_8.InvokeMethodOnTarget() +67
   Castle.DynamicProxy.AbstractInvocation.Proceed() +80
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:53
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:45
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:35
   Castle.DynamicProxy.AbstractInvocation.Proceed() +108
   Castle.Proxies.EfRepositoryBase`2Proxy_2.Get(Int32 id) +155
   Abp.MultiTenancy.TenantCache`2.GetTenant(Int32 tenantId) in D:\Halil\GitHub\module-zero\src\Abp.Zero\MultiTenancy\TenantCache.cs:60
   Castle.Proxies.TenantCache`2Proxy.GetTenant_callback(Int32 tenantId) +5
   Castle.Proxies.Invocations.TenantCache`2_GetTenant.InvokeMethodOnTarget() +67
   Castle.DynamicProxy.AbstractInvocation.Proceed() +80
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:53
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:45
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:35
   Castle.DynamicProxy.AbstractInvocation.Proceed() +108
   Castle.Proxies.TenantCache`2Proxy.GetTenant(Int32 tenantId) +155
   Abp.MultiTenancy.<>c__DisplayClass4_0.<Get>b__0() in D:\Halil\GitHub\module-zero\src\Abp.Zero\MultiTenancy\TenantCache.cs:37
   Abp.Runtime.Caching.<>c__DisplayClass0_0`2.&lt;Get&gt;b__0(TKey k) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Caching\TypedCacheExtensions.cs:13
   Abp.Runtime.Caching.&lt;&gt;c__DisplayClass3_0`2.<Get>b__0(String k) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Caching\CacheExtensions.cs:28
   Abp.Runtime.Caching.CacheBase.Get(String key, Func`2 factory) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Caching\CacheBase.cs:42
   Abp.Runtime.Caching.CacheExtensions.Get(ICache cache, TKey key, Func`2 factory) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Caching\CacheExtensions.cs:28
   Abp.Runtime.Caching.TypedCacheWrapper`2.Get(TKey key, Func`2 factory) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Caching\TypedCacheWrapper.cs:52
   Abp.Runtime.Caching.TypedCacheExtensions.Get(ITypedCache`2 cache, TKey key, Func`1 factory) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Runtime\Caching\TypedCacheExtensions.cs:13
   Abp.MultiTenancy.TenantCache`2.Get(Int32 tenantId) in D:\Halil\GitHub\module-zero\src\Abp.Zero\MultiTenancy\TenantCache.cs:31
   Castle.Proxies.TenantCache`2Proxy.Get_callback(Int32 tenantId) +5
   Castle.Proxies.Invocations.TenantCache`2_Get.InvokeMethodOnTarget() +66
   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.TenantCache`2Proxy.Get(Int32 tenantId) +155
   Abp.Zero.EntityFramework.DbPerTenantConnectionStringResolver.GetNameOrConnectionString(DbPerTenantConnectionStringResolveArgs args) in D:\Halil\GitHub\module-zero\src\Abp.Zero.EntityFramework\Zero\EntityFramework\DbPerTenantConnectionStringResolver.cs:51
   Abp.Zero.EntityFramework.DbPerTenantConnectionStringResolver.GetNameOrConnectionString(ConnectionStringResolveArgs args) in D:\Halil\GitHub\module-zero\src\Abp.Zero.EntityFramework\Zero\EntityFramework\DbPerTenantConnectionStringResolver.cs:46
   Abp.Domain.Uow.UnitOfWorkBase.ResolveConnectionString(ConnectionStringResolveArgs args) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkBase.cs:332
   Abp.EntityFramework.Uow.EfUnitOfWork.GetOrCreateDbContext(Nullable`1 multiTenancySide) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\Uow\EfUnitOfWork.cs:145
   Abp.EntityFramework.Uow.UnitOfWorkExtensions.GetDbContext(IActiveUnitOfWork unitOfWork, Nullable`1 multiTenancySide) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\Uow\UnitOfWorkExtensions.cs:38
   Abp.EntityFramework.Uow.UnitOfWorkDbContextProvider`1.GetDbContext(Nullable`1 multiTenancySide) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\Uow\UnitOfWorkDbContextProvider.cs:38
   Castle.Proxies.EfRepositoryBase`3Proxy_11.get_Context_callback() +46
   Castle.Proxies.Invocations.EfRepositoryBase`3_get_Context_14.InvokeMethodOnTarget() +28
   Castle.DynamicProxy.AbstractInvocation.Proceed() +80
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:53
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:45
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:35
   Castle.DynamicProxy.AbstractInvocation.Proceed() +108
   Castle.Proxies.EfRepositoryBase`3Proxy_11.get_Context() +126
   Abp.EntityFramework.Repositories.EfRepositoryBase`3.get_Table() in D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\Repositories\EfRepositoryBaseOfTEntityAndTPrimaryKey.cs:30
   Castle.Proxies.EfRepositoryBase`3Proxy_11.get_Table_callback() +5
   Castle.Proxies.Invocations.EfRepositoryBase`3_get_Table_14.InvokeMethodOnTarget() +28
   Castle.DynamicProxy.AbstractInvocation.Proceed() +80
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:53
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:45
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:35
   Castle.DynamicProxy.AbstractInvocation.Proceed() +108
   Castle.Proxies.EfRepositoryBase`3Proxy_11.get_Table() +126
   Abp.EntityFramework.Repositories.EfRepositoryBase`3.InsertAsync(TEntity entity) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\Repositories\EfRepositoryBaseOfTEntityAndTPrimaryKey.cs:80
   Castle.Proxies.EfRepositoryBase`3Proxy_11.InsertAsync_callback(AuditLog entity) +5
   Castle.Proxies.Invocations.EfRepositoryBase`3_InsertAsync_14.InvokeMethodOnTarget() +68
   Castle.DynamicProxy.AbstractInvocation.Proceed() +80
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:62
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformUow(IInvocation invocation, UnitOfWorkOptions options) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:41
   Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:35
   Castle.DynamicProxy.AbstractInvocation.Proceed() +108
   Castle.Proxies.EfRepositoryBase`3Proxy_11.InsertAsync(AuditLog entity) +141
   Abp.Auditing.AuditingStore.SaveAsync(AuditInfo auditInfo) in D:\Halil\GitHub\module-zero\src\Abp.Zero\Auditing\AuditingStore.cs:24
   Abp.Auditing.&lt;&gt;c__DisplayClass0_0.&lt;Save&gt;b__0() in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Auditing\AuditingStoreExtensions.cs:17
   System.Threading.Tasks.Task`1.InnerInvoke() +56
   System.Threading.Tasks.Task.Execute() +49
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   Nito.AsyncEx.<>c__DisplayClass3.<Run>b__1(Task t) +56
   System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() +52
   System.Threading.Tasks.Task.Execute() +49
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   Nito.AsyncEx.AsyncContext.Run(Func`1 action) +201
   Abp.Auditing.AuditingStoreExtensions.Save(IAuditingStore auditingStore, AuditInfo auditInfo) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Auditing\AuditingStoreExtensions.cs:17
   Abp.Web.Mvc.Controllers.AbpController.HandleAuditingAfterAction(ActionExecutedContext filterContext) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.Web.Mvc\Web\Mvc\Controllers\AbpController.cs:466
   Castle.Proxies.AccountControllerProxy.OnActionExecuted_callback(ActionExecutedContext filterContext) +5
   Castle.Proxies.Invocations.AbpController_OnActionExecuted.InvokeMethodOnTarget() +69
   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.OnActionExecuted(ActionExecutedContext filterContext) +142
   System.Web.Mvc.Controller.System.Web.Mvc.IActionFilter.OnActionExecuted(ActionExecutedContext filterContext) +9
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass46.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3f() +253
   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.System.Web.HttpApplication.IExecutionStep.Execute() +9644097
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0

2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    There should be a Default Tenant with Id = 1 in the databse (abptenants table). Migration Seed code should insert it. Have you run migrations (update-database)?

  • User Avatar
    0
    sergii created

    Hi, thank you for answer. Yes, the issue was in migration scripts... Resolved by recreating database and new migration scripts.