Base solution for your next web application
Open Closed

Issue with New Abp Update 0.9.2.0 #1247


User avatar
0
maharatha created

I have upgraded to the latest version of Abp and my audit Log has stopped working. Below is the error I am getting

ERROR 2016-06-06 05:10:00,794 [70 ] lers.Filters.AbpExceptionFilterAttribute - Attaching an entity of type 'xxxxx.xxxxx.Authorization.Users.User' failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph have conflicting key values. This may be because some entities are new and have not yet received database-generated key values. In this case use the 'Add' method or the 'Added' entity state to track the graph and then set the state of non-new entities to 'Unchanged' or 'Modified' as appropriate. System.InvalidOperationException: Attaching an entity of type 'xxxxx.xxxxx.Authorization.Users.User' failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph have conflicting key values. This may be because some entities are new and have not yet received database-generated key values. In this case use the 'Add' method or the 'Added' entity state to track the graph and then set the state of non-new entities to 'Unchanged' or 'Modified' as appropriate. at System.Data.Entity.Core.Objects.ObjectContext.VerifyRootForAdd(Boolean doAttach, String entitySetName, IEntityWrapper wrappedEntity, EntityEntry existingEntry, EntitySet& entitySet, Boolean& isNoOperation) at System.Data.Entity.Core.Objects.ObjectContext.AttachTo(String entitySetName, Object entity) at System.Data.Entity.Internal.Linq.InternalSet1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) at System.Data.Entity.Internal.Linq.InternalSet1.Attach(Object entity) at Abp.EntityFramework.Uow.EfUnitOfWork.ObjectContext_ObjectMaterialized(DbContext dbContext, ObjectMaterializedEventArgs e) at System.Data.Entity.Core.Objects.ObjectContext.OnObjectMaterialized(Object entity) at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.RaiseMaterializedEvents() at System.Data.Entity.Core.Common.Internal.Materialization.Shaper1.StopMaterializingElement() at System.Data.Entity.Core.Common.Internal.Materialization.Shaper1.SimpleEnumerator.<MoveNextAsync>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.<ForEachAsync>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at xxxxx.xxxxx.Auditing.AuditLogAppService.<GetAuditLogs>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at xxxxx.xxxxx.Interceptors.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__31.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()


3 Answer(s)
  • User Avatar
    0
    maharatha created

    I made this change and it works :

    public async Task<PagedResultOutput<AuditLogListDto>> GetAuditLogs(GetAuditLogsInput input) { var query = CreateAuditLogAndUsersQuery(input); var resultCount = await query.CountAsync(); var results = await query // .AsNoTracking() .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); var auditLogListDtos = ConvertToAuditLogListDtos(results); return new PagedResultOutput<AuditLogListDto>(resultCount, auditLogListDtos); }

    Is this correct?

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Thank you very much for your bug report. Yes, there is an issue like that. Your current workaround is good. You can even use that code even after we fix it, since you are using paging and tracking 10 items has no performance problem. We will fix this soon: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/issues/232">https://github.com/aspnetzero/aspnet-zero/issues/232</a>

  • User Avatar
    0
    maharatha created

    Thanks Hilkan the new release fixed it