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)

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
713 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,521 questions
{count} votes