^O^ 发表于 2023-6-5 16:48:31

【F-16130】增加组织机构 错误500

本帖最后由 Simon.Sun 于 2023-6-7 11:41 编辑

Request failed with status code 500

异常调用堆栈:{ "ClassName": "Microsoft.EntityFrameworkCore.DbUpdateException", "Message": "An error occurred while saving the entity changes. See the inner exception for details.", "Data": null, "InnerException": { "$type": "MySqlConnector.MySqlException, MySqlConnector", "ClassName": "MySqlConnector.MySqlException", "Message": "Field 'ID' doesn't have a default value", "Data": null, "InnerException": null, "HelpURL": null, "StackTraceString": " at MySqlConnector.Core.ServerSession.ReceiveReplyAsyncAwaited(ValueTask`1 task) in /_/src/MySqlConnector/Core/ServerSession.cs:line 956 at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in /_/src/MySqlConnector/Core/ResultSet.cs:line 44 at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 108 at MySqlConnector.MySqlDataReader.CreateAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, IDictionary`2 cachedProcedures, IMySqlCommand command, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 456 at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(IReadOnlyList`1 commands, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/CommandExecutor.cs:line 56 at MySqlConnector.MySqlCommand.ExecuteReaderAsync(CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 331 at MySqlConnector.MySqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 323 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)", "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": null, "HResult": -2147467259, "Source": "MySqlConnector", "WatsonBuckets": null, "Number": 1364, "SqlState": "HY000" }, "HelpURL": null, "StackTraceString": " at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.<>c__DisplayClass33_0`2.<<ExecuteAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementationAsync(Func`4 operation, Func`4 verifySucceeded, TState state, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementationAsync(Func`4 operation, Func`4 verifySucceeded, TState state, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteAsync(TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Forguncy.UserService2.Services.OrganizationStructureService.AddOrgStructureAsync(AddOrganizationParam param) at Forguncy.UserService2.Controllers.New.OrganizationStructureController.AddOrgStructureAsync(AddOrganizationParam param) at lambda_method1238(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Forguncy.UserService2.KatanaMiddleware.ControllerMiddleware.InvokeAsync(HttpContext context) at Forguncy.UserService2.KatanaMiddleware.AdminPortalFrontMiddleware.InvokeAsync(HttpContext context) at ForguncyServerCommon.HttpHeaderMiddlewareBase.InvokeAsync(HttpContext context) at Forguncy.KatanaMiddleware.u.InvokeAsync(HttpContext context)", "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": null, "HResult": -2146233088, "Source": "Microsoft.EntityFrameworkCore.Relational", "WatsonBuckets": null }; | 用户名:administrator; | 请求路径:/OrganizationStructure/AddOrgStructure;      



Simon.Sun 发表于 2023-6-5 16:48:32

您好,看错误是数据库报的错,您那边检查下外联库中用户相关的表的 ID 有没有设置主键自增,没有勾选一下试试,主要检查下组织机构相关的表,如下:

^O^ 发表于 2023-6-5 17:54:47

Simon.Sun 发表于 2023-6-5 17:50
您好,看错误是数据库报的错,您那边检查下外联库中用户相关的表的 ID 有没有设置主键自增,没有勾选一下试 ...

原来版本都是不自增的,改了应该对原有的问题进行修复

Simon.Sun 发表于 2023-6-5 18:22:15

本帖最后由 Simon.Sun 于 2023-6-7 11:39 编辑

一般我们升级是会自动跑升级脚本的,所以一般不会出现上面情况。这边测试下从 8 到 9 看能不能复现您说的情况。
有结果会继续在此贴跟进,感谢您的反馈。

问题跟进,这个是这边的一个问题,用户外联数据库(MySQL 8)从 8 切换的 9 有此问题,解决办法就是将自增勾选就可以。我们后面会在后续版本修复此问题,感谢您的反馈。

Simon.hu 发表于 2023-8-11 12:01:16

此bug已经修改,请在活字格官网下载最新的安装包9.0.6.0体验。
页: [1]
查看完整版本: 【F-16130】增加组织机构 错误500