linkKeyProperty where to set in a Palette based model

I have a palette that has different categories of nodes and a link. I can set the linkkeyProperty during the initialization of the Palette as below and I get a ‘key1’ parameter for the link when I drag a link from palette. But when I create a link between nodes within the gojs diagram area by clicking the mouse on a port and then dragging out a link to connect to another port, I don’t get the ‘key1’ parameter for the link. I suppose the Link comes from the LinkTemplate definition for the myDiagram. I have tried setting the linkKeyProperty for mydiagram.model but that is not giving me a key parameter for the link. How to set linkKeyProperty for the LinkTemplate so that a key will be generated for the link when I create a link using the mouse click within the gojs Diagram area?

myPalette.model = new go.GraphLinksModel([]);
myPalette.model.linkKeyProperty = “key1”;
//myPalette.model.linkFromPortIdProperty = “fromPort”;
myPalette.model.makeUniqueKeyFunction = keyGenerator;
//myPalette.model.makeUniqueLinkKeyFunction = linkKeyGenerator;
myPalette.model.nodeDataArray = [{ category: “Table”, name: “Table”, color: “green”, button: “Edit”},
{ category: “Join”, name: “Join”},
{ category: “Project”, text: “Project” },
{ category: “Filter”, text: “Filter” },
{ category: “Group”, text: “Group” },
{ category: “Sort”, text: “Sort” },
//{ category: “output”, text:“Output”}
];

myDiagram.model = $(go.GraphLinksModel,
{
nodeKeyProperty: ‘stepId’,
linkKeyProperty: ‘key1’,
linkFromKeyProperty: ‘fromId’,
linkToKeyProperty: ‘toId’,
}
);

Your code looks correct. Maybe you are replacing the Diagram.model with a GraphLinksModel that doesn’t have linkKeyProperty set to “key1”.

Thanks - you were correct, the graphlinks model was being reset in the load() function. I fixed that and everything worked right.