The below code is used to associate the workflow to the list as well as the update the workflow association to the sharepoint list
// Add workflow association to my list
if (hasWorkflowAssociation == null)
{
sharePointSitesList.WorkflowAssociations.Add(workflowAssociation);
// Enable workflow
workflowAssociation.Enabled = true;
}
else
{
hasWorkflowAssociation.Enabled = true;
sharePointSitesList.UpdateWorkflowAssociation(hasWorkflowAssociation);
sharePointSitesList.Update();
}
// Add workflow association to my list
if (hasWorkflowAssociation == null)
{
sharePointSitesList.WorkflowAssociations.Add(workflowAssociation);
// Enable workflow
workflowAssociation.Enabled = true;
}
else
{
hasWorkflowAssociation.Enabled = true;
sharePointSitesList.UpdateWorkflowAssociation(hasWorkflowAssociation);
sharePointSitesList.Update();
}