0
votes

With Kentico 13, I'm looking for a way to specify the primary key value when inserting a TreeNode via API. Something like:

var node = TreeNode.New("MyPageType");
node.SetValue("MyPageTypeID", 1234);
node.Insert(parentNode);

This needs to set the primary key in the MyPageType table so needs SQL identity insert on, and also needs to set the DocumentForeignKeyValue in the CMS_Document table.

The only way I have thought of doing it is with some custom SQL after the node is created, but feels like a hack. Is there a better way?

This is for a content migration task of thousands of documents. After the content migration the default SQL & primary key behavior will be used.

1

1 Answers

0
votes

In case anyone finds this, the solution I came up with was to run the content migration script with the old primary key value in a temporary column. After migration I ran SQL to update Kentico references to the old primary key, remove the old primary key, and change the primary key to the temporary column. A bit nasty, but got the job done.