childAgg

سوال شده توسط: Amir Taha Zahraei

تاریخ ثبت: ۱۴۰۱/۰۷/۲۴

بازدید: 333

پاسخ: 5

تگ: Asp.net Core


سلام استاد 

وقتی میخوام چایلد اگریگیت ها رو تو دی بی ذخیره کنم این ارور رو میده 

{
  "IsSuccess": false,
  "MetaData": {
    "Message": "{\"Exception\":\"The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.\",\"StackTrace\":\"   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected)\\r\\n   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithoutPropagationAsync(Int32 commandIndex, RelationalDataReader reader, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)\\r\\n   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)\\r\\n   at Infrastructure.Persistent.Ef.ApplicationDbContext.SaveChangesAsync(CancellationToken cancellationToken) in D:\\\\Working\\\\Dot Net Core Projects\\\\My\\\\Book\\\\Shop\\\\Infrastructure\\\\Persistent.Ef\\\\ApplicationDbContext.cs:line 45\\r\\n   at Infrastructure._Utilities.BaseRepository`1.Save() in D:\\\\Working\\\\Dot Net Core Projects\\\\My\\\\Book\\\\Shop\\\\Infrastructure\\\\_Utilities\\\\BaseRepository.cs:line 47\\r\\n   at Application.Users.AddToken.AddUserTokenCommandHandler.Handle(AddUserTokenCommand request, CancellationToken cancellationToken) in D:\\\\Working\\\\Dot Net Core Projects\\\\My\\\\Book\\\\Shop\\\\Application\\\\Users\\\\AddToken\\\\AddUserTokenCommandHandler.cs:line 24\\r\\n   at Common.Application.Validation.CommandValidationBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken) in D:\\\\Working\\\\Dot Net Core Projects\\\\My\\\\Book\\\\Common\\\\Common.Application\\\\Validation\\\\CommandValidationBehavior.cs:line 39\\r\\n   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)\\r\\n   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)\\r\\n   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)\\r\\n   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)\\r\\n   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)\\r\\n   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, RequestHandlerDelegate`1 next, CancellationToken cancellationToken)\\r\\n   at Presentation.Facade.Users.UserFacade.AddToken(AddUserTokenCommand command) in D:\\\\Working\\\\Dot Net Core Projects\\\\My\\\\Book\\\\Shop\\\\Presentation.Facade\\\\Users\\\\UserFacade.cs:line 40\\r\\n   at Api.Controllers.AuthController.AddTokenAndGenerateJwt(UserDto user) in D:\\\\Working\\\\Dot Net Core Projects\\\\My\\\\Book\\\\Shop\\\\Api\\\\Controllers\\\\AuthController.cs:line 115\\r\\n   at Api.Controllers.AuthController.Login(LoginViewModel loginViewModel) in D:\\\\Working\\\\Dot Net Core Projects\\\\My\\\\Book\\\\Shop\\\\Api\\\\Controllers\\\\AuthController.cs:line 51\\r\\n   at lambda_method6(Closure , Object )\\r\\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\\r\\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)\\r\\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\\r\\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\\r\\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\\r\\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\\r\\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\\r\\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)\\r\\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)\\r\\n   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)\\r\\n   at Common.AspNetCore.Middlewares.ApiCustomExceptionHandlerMiddleware.Invoke(HttpContext context) in D:\\\\Working\\\\Dot Net Core Projects\\\\My\\\\Book\\\\Common\\\\Common.AspNetCore\\\\Middlewares\\\\ApiCustomExceptionHandler.cs:line 43\"}",
    "AppStatusCode": 6
  }
}
پاسخ ها
user

محمد اشرافی

سلام وقت بخیر   اول از هر چیز چک کنید که به صورت with Many توی user configuration تعریف شده باشه و اسم تیبل و فیلد های ساخته شده توی دیتابیس دقیقا همون باشه که تعریف کردین و بعد مطمعا بشید که فقط یک جا به صورت tracking صدا زده باشه ( یعنی فقط توی همون متد )

user

Amir Taha Zahraei

من چک کردم 

همش درست بود 

ولی درست نشد 

اینم کد هاش

دریافت فایل ضمیمه
user

Amir Taha Zahraei

الان یدونه کتگوری ادد کردم 

بعدش میخواستم یدونه با پرنت ای دی ادد کنم هم همین ارور رو داد با اینکه چایلد اگریگیت نبود 

به صورت دستی میتونم تو دیتا بیس ادد کنم اما تو اپ ارور میده

user

Amir Taha Zahraei

اصلا متد های اپدیت کار نمیکنن

بدون گت ترکینگ هم زدم اما کار نمیکنه 

منظورم بدون ترکینگ همون حالتیه که گت با ای دی خالی میکنی بعد اپدیت و بعد سیو

user

Amir Taha Zahraei

این قسمت رو به دیبی کانتکس اضافه کردم و درست شد

اما نفهمیدم مشکل از کجا بود 

به نظرتون مشکل چی بود

دریافت فایل ضمیمه
برای ثبت پاسخ باید خود شوید

محبوب ترین مقالات