how to solve:An unhandled exception occurred while processing the request. SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Doctors_Users_UserId".

karen matungwa 0 Reputation points
2024-05-26T19:23:31.6466667+00:00

An unhandled exception occurred while processing the request.

SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Doctors_Users_UserId". The conflict occurred in database "Diabetes2AppDb", table "dbo.Users", column 'Id'.

Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)

DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.

Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetAsync(int startCommandIndex, RelationalDataReader reader, CancellationToken cancellationToken)

Developer technologies | .NET | Entity Framework Core
Developer technologies | C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.