Open Closed

Issues with abp modules and inverse navigational property I get A possible object cycle was detected. #2393


User avatar
0
dekiyana@gmail.com created

Hi guys thanks for your help in advance I have 3 Entities Masterorder, transportorder and jobs in a abp module I would like to make and inverse navigational property but I get an error "A possible object cycle was detected. This can either be" with no details I have gone through the entity framework documentation and followed the steps however if I am making an inverse navigational property in a non abp module (solution) I get no error I will add my entities below and my stack trace below my entities, I am not sure if i am creating my entity properly or is it how im handeling entity framework

MasterOrderEntity

`
    public class MasterOrder : FullAuditedAggregateRoot<Guid>, IMultiTenant
    {
        [InverseProperty("MasterOrder")]
        public ICollection<TransportOrder> TransportOrders { get; set; }
        public MasterOrder()
        {
           
        }
    }`

TransportOrder Entity

`
   public class TransportOrder : FullAuditedAggregateRoot<Guid>, IMultiTenant
    {

        [InverseProperty("TransportOrder")]
        public List<Job> Jobs { get; set; }
        
        public MasterOrder masterOrder { get; set; }

        public TransportOrder()
        {
            Jobs = new List<Job>();
            Id = Guid.NewGuid();
        }

   
        public TransportOrder transportOrder { get; set; }

        public Job()
        {

        }

        
    }
    `

Stack Trace

SET NOCOUNT ON; INSERT INTO [AbpAuditLogs] ([Id], [ApplicationName], [BrowserInfo], [ClientId], [ClientIpAddress], [ClientName], [Comments], [ConcurrencyStamp], [CorrelationId], [Exceptions], [ExecutionDuration], [ExecutionTime], [ExtraProperties], [HttpMethod], [HttpStatusCode], [ImpersonatorTenantId], [ImpersonatorUserId], [TenantId], [TenantName], [Url], [UserId], [UserName]) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14, @p15, @p16, @p17, @p18, @p19, @p20, @p21); 2022-01-10 13:46:40.506 +08:00 [ERR] An exception occurred in the database while saving changes for context type 'Volo.Abp.AuditLogging.EntityFrameworkCore.AbpAuditLoggingDbContext'. Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> Microsoft.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated in table 'gtcdb.dbo.AbpAuditLogs', column 'Exceptions'. Truncated value: '[ { "code": null, "message": "A possible object cycle was detected. This can either be '. The statement has been terminated. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__169_0(Task1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) ClientConnectionId:2d6cfc34-e2f0-49a2-afde-eda1301e04eb Error Number:2628,State:1,Class:16 --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.


1 Answer(s)
  • User Avatar
    0
    yekalkan created
    Support Team Fullstack Developer

    Hi @dekiyana,

    This is not a suggested way to relate Aggregate Roots, by ABP and DomainDrivenDesign. Check the note section in Add Relation to The Book Entity section: https://docs.abp.io/en/abp/latest/Tutorials/Part-10?UI=MVC&DB=EF#add-relation-to-the-book-entity

    However, as the note stated, you can do it your way if you want. I think you have to check your implementation. I've found a stackoverflow question similar to yours: https://stackoverflow.com/questions/59199593/net-core-3-0-possible-object-cycle-was-detected-which-is-not-supported

Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35