The full error:
System.Data.SqlClient.SqlException: the UPDATE statement conflicted with the FOREIGN KEY constraint \"FK__Product__Categor__1FCDBCEB\". The conflict occurred in database \"dbi416547_i416547\", table \"dbo.Category\", column 'CategoryID'.
Now I tried looking it up and found: Sql error on update : The UPDATE statement conflicted with the FOREIGN KEY constraint
But I don't know how to modify the foreign key in visual studio 2019. Also I don't understand where I would put the rule using T-SQL, because my table goes like:
CREATE TABLE [dbo].[Product]
(
[ProductID] INT IDENTITY (1, 1) NOT NULL,
[UserID] INT NOT NULL,
[Name] NVARCHAR(50) NOT NULL,
[Price] DECIMAL(18) NOT NULL,
[Description] NVARCHAR(50) NOT NULL,
[CategoryID] INT NOT NULL,
[Photo] NVARCHAR(50) NULL,
[Likes] INT NULL,
PRIMARY KEY CLUSTERED ([ProductID] ASC),
FOREIGN KEY ([UserID]) REFERENCES [dbo].[User] ([UserID]),
FOREIGN KEY ([CategoryID]) REFERENCES [dbo].[Category] ([CategoryID])
);
And if I put it underneath or between the ( ) I still get errors. Any suggestions?