Here is a new issue. Trying to update entry in the Database. Note, this entry has dependency on User. I conducted the same logic I used to do when I didn't have user association with the item without any issue. However, now it is giving me grief. Here is the screenshot, enter image description here
Here is the details on the exception note System.InvalidOperationException HResult=0x80131509 Message=The property 'Id' on entity type 'Medication' has a temporary value while attempting to change the entity's state to 'Modified'. Either set a permanent value explicitly or ensure that the database is configured to generate values for this property. Source=Microsoft.EntityFrameworkCore StackTrace: at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState oldState, EntityState newState, Boolean acceptChanges, Boolean modifyProperties) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState entityState, Boolean acceptChanges, Boolean modifyProperties, Nullable`1 forceStateWhenUnknownKey) at Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry.set_State(EntityState value) at MedicalManager.Models.Repositories.MedicationRepository.UpdateMedication(Medication medication, String UserId) in C:\bite-us\stackoverflow\mmm_development\MedicalManager\Models\Repositories\MedicationRepository.cs:line 71 at MedicalManager.Controllers.HomeController.Edit(Medication medication) in Z0D61F8370CAD1D412F80B84D143E125 7Z:\bite-us\stackoverflow\mmm_development\MedicalManager\Controllers\HomeController.cs:line 123 at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.