FOREIGN KEY constraint SQL Error while creating a new page programmatically

Vote:
 

I get this DB Error on saving a new page programmatically:

"The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_tblWorkContentProperty_tblContent\". The conflict occurred in database \"MyDbName\", table \"dbo.tblContent\", column 'pkID'."

The code which always worked is:

public static ContentReference SaveContentToPublishWithNoAccess(this IContentRepository contentRepository, IContent content)
{
    return contentRepository.Save(content, SaveAction.Publish, AccessLevel.NoAccess);
}

What can be the reason? This happens only for one page that i am creating but i cannot see a difference to the others.
I have restarted IIS and cleared the trash. Since it's on local i can also debug.

#208665
Edited, Oct 29, 2019 18:25
Vote:
 

Hi Tim,

Are you using shared database? I mean, same database is being used by other developers too?

The following link might be related

https://world.episerver.com/forum/legacy-forums/Episerver-7-CMS/Thread-Container/2013/4/SQL-constraint-violation-when-creating-new-block/

If not, please let me know

#208668
Oct 29, 2019 21:02
Tim Schmelter - Oct 30, 2019 9:58
Thank you. But unfortunately it didn't help because every developer has his own DB locally. This didn't help either:
-Restart IIS / Restart website / Recycle application pool
-Clear browser cache
-Restart browser
I have also tried to reset the identity seed for the tblContent.pkId column which also didn't change anything.
Vote:
 

Do you say that this error occurs only for one page that you are creating? And not for other pages you are creating?

Same page type, or different page type?

#208706
Oct 30, 2019 13:42
Tim Schmelter - Oct 30, 2019 13:56
Same page type and currently only with one page. I couldn't test yet if it also occurs on other computers or if it is a local issue.
It's a "Job Page" and the error comes during importing the new jobs. The updates/deletes are no problem.
- Oct 30, 2019 14:05
Could you share the code where you create the new page, and populates its properties?
Tim Schmelter - Oct 30, 2019 14:19
I have updated my question with the relevant code. Edit: Removed the code again
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.