<p>
This can be done programatically or declaratively. Below is section of code that do it programtically.
</p>
<pre data-sub="prettyprint:_">
private static void AddServices(WorkflowRuntime instance)
{
String connStringPersistence = String.Format(
"Initial Catalog={0};Data Source={1};Integrated Security={2};",
"workflow", @".", "SSPI");
instance.AddService(
new SqlWorkflowPersistenceService(connStringPersistence, true,
new TimeSpan(0, 2, 0), new TimeSpan(0, 0, 5)));
}
</pre>
<p>
To do it declaratively, you need to change your code and the configuration file as well. Here is a section of code
</p>
<code>
//here you use a constructor to specify the configSectionName
WorkflowRuntime runtime = new WorkflowRuntime("WorkflowRuntime")
</pre>
<p>
You should add you configsection in the config file. Please note that the name of the section does not necessary to be "WorkflowRuntime"
</p>
<code>
<configuration>
<configSections>
<section name="WorkflowRuntime"
type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection,
System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</configSections>
<WorkflowRuntime Name="ConsoleHostingManaged" >
<CommonParameters>
<!--Add parameters common to all services-->
<add name="ConnectionString"
value="Initial Catalog=workflow;
Data Source=localhost;
Integrated Security=SSPI;" />
</CommonParameters>
<Services>
<!--Add core services here-->
<add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService,
System.Workflow.Runtime, Version=3.0.00000.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
UnloadOnIdle="true" LoadIntervalSeconds="5" />
</Services>
</WorkflowRuntime>
</configuration>
</pre>