Open Closed

Error when adding a multiple choice question in a Tenant form #2882


User avatar
0
Mikael created

ABP Commercial 5.2.0 Stable EF SQL

On a new project, I cannot create Multiple Choice question in a form if I am logged in within a Tenant. The following error occurs.

This was happening in 5.2.0 RC also.

Mikael

2022-04-11 13:36:57.650 +02:00 [INF] Route matched with {controller = "Form", area = "form", action = "Update", page = ""}. Executing controller action with signature System.Threading.Tasks.Task1[Volo.Forms.Questions.QuestionDto] UpdateAsync(System.Guid, Volo.Forms.Questions.UpdateQuestionDto) on controller Volo.Forms.Questions.QuestionController (Volo.Forms.HttpApi). 2022-04-11 13:36:57.729 +02:00 [ERR] Failed executing DbCommand (7ms) [Parameters=[@p0='?' (DbType = Guid), @p1='?' (Size = 40)], CommandType='"Text"', CommandTimeout='30'] SET NOCOUNT ON; DELETE FROM [FrmQuestions] WHERE [Id] = @p0 AND [ConcurrencyStamp] = @p1; SELECT @@ROWCOUNT; 2022-04-11 13:36:57.784 +02:00 [ERR] An exception occurred in the database while saving changes for context type 'Volo.Forms.EntityFrameworkCore.FormsDbContext'. Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details. ---> Microsoft.Data.SqlClient.SqlException (0x80131904): The DELETE statement conflicted with the REFERENCE constraint "FK_FrmChoices_FrmQuestions_ChoosableQuestionId". The conflict occurred in database "TestingMTM", table "dbo.FrmChoices", column 'ChoosableQuestionId'. The statement has been terminated. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_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:c1abcf1e-da8d-4c40-8a12-7837483ee83d Error Number:547,State:0,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(StateManager stateManager, 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 saving the entity changes. See the inner exception for details. ---> Microsoft.Data.SqlClient.SqlException (0x80131904): The DELETE statement conflicted with the REFERENCE constraint "FK_FrmChoices_FrmQuestions_ChoosableQuestionId". The conflict occurred in database "TestingMTM", table "dbo.FrmChoices", column 'ChoosableQuestionId'. The statement has been terminated. at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_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:c1abcf1e-da8d-4c40-8a12-7837483ee83d Error Number:547,State:0,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(StateManager stateManager, 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) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Volo.Abp.EntityFrameworkCore.AbpDbContext1.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`2.DeleteAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) 2022-04-11 13:36:57.829 +02:00 [ERR] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "An internal error occurred during your request!", "details": null, "data": {}, "validationErrors": null }


3 Answer(s)
  • User Avatar
    0
    Mikael created

    Additional info: I see that the TenantId is not populated in the FrmChoices (if I add it manually in the DB, I can edit once but it removes it during the edit also):

    Id TenantId ChoosableQuestionId IsCorrect Index Value E60DB298-D2EC-45B1-99D7-3A032A94D68D NULL 04416E4A-6760-C6DE-FABF-3A032A94B18E 0 1 zefezfa 32F4B0E0-56E0-9BE9-D7B5-3A032A94D68E NULL 04416E4A-6760-C6DE-FABF-3A032A94B18E 0 3 Other...

    C87DB08B-B766-6D88-EEB9-3A032A94D68E NULL 04416E4A-6760-C6DE-FABF-3A032A94B18E 0 2 zefze 85171D6D-A164-9FD0-86BE-3A032A94F749 NULL 9735F5D2-7B2E-9E9E-AB63-3A032A94D85C 0 2 zaefzaef 924333ED-680A-E510-F882-3A032A94F749 NULL 9735F5D2-7B2E-9E9E-AB63-3A032A94D85C 0 1 azefzae C0209865-9591-F151-89D1-3A032A967327 NULL 4D1828BD-C9CB-9332-05C4-3A032A966658 0 1 Option 71D13037-9FD0-B82D-8AF6-3A032B6A0CC8 NULL 70F54A35-F7EB-B229-F35D-3A032B69FE57 0 1 Option 179B80FB-8B46-5974-3192-3A032B6FD905 NULL A038E366-19DE-E1AF-8474-3A032B6FBF85 0 1 Optiondd

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Thank you for your report, we will investigate.

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Thank you, we have reproduced this problem about multi-tenancy. I have created an internal issue for this. It will be fixed in the next release hopefully.

    I have refunded your question credit.

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