0

I want users to be able to edit what they already created and save the changes to the db. When I test editing out, I get this error:

enter image description here

SqlException: The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_REPTILES_AspNetUsers_ApplicationUserId". The conflict occurred in database "PetAdoptDB", table "dbo.AspNetUsers", column "Id"

I tried modifying the foreign key to cascade instead of no action which I found here Link, but, I still get the error.

While debugging I noticed that the ApplicationUser is null and ApplicationUserId equals 0 when running

_context.Update(reptile);

Not sure if that's the problem or not and if so, how to fix it.

1 Answers1

0

I got it working by using <input type="hidden" asp-for="ApplicationUserId" /> within the form on the edit page.