Are Dynamics CRM plugins registered as "post operation" run inside or outside the DB transaction?
<p>I'm working on plugin registration for custom C# plugins for Dynamics CRM (2015 and CRM Online).</p>

<p>When you create a new plugin using the Visual Studio CRM Explorer, you get the standard "Create Plug-in" dialog:</p>

<p><a href="https://i.stack.imgur.com/LriWf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LriWf.png" alt="enter image description here"></a></p>

<p>Under "Pipeline Stage", there are three options:</p>

<ol>
<li>Pre-Validation</li>
<li>Pre-Operation</li>
<li>Post-Operation</li>
</ol>

<p>Selecting <code>Post-Operation</code> here results in this code being added to the XML registration file:</p>

<pre><code>    &lt;Plugin Description="..." FriendlyName="PostContactCreate" Name="Cacheron.PostContactCreate" Id="00000000-0000-0000-0000-000000000000" TypeName="Cacheron.PostContactCreate"&gt;
      &lt;Steps&gt;
        &lt;clear /&gt;
        &lt;Step CustomConfiguration="" Name="PostContactCreate" Description="Post-Operation of Contact Create" Id="00000000-0000-0000-0000-000000000000" MessageName="Create" Mode="Synchronous" PrimaryEntityName="contact" Rank="1" SecureConfiguration="" Stage="PostOutsideTransaction" SupportedDeployment="ServerOnly"&gt;
          &lt;Images /&gt;
        &lt;/Step&gt;
      &lt;/Steps&gt;
    &lt;/Plugin&gt;
</code></pre>

<p>The key part there is that middle line, where it says <code>Stage="PostOutsideTransaction"</code></p>

<p>The corresponding C# code that's generated by the tool includes the line:</p>

<pre><code>base.RegisteredEvents.Add(
  new Tuple&lt;int, string, string, Action&lt;LocalPluginContext&gt;&gt;(
    40, 
    "Create", 
    "contact", 
    new Action&lt;LocalPluginContext&gt;(ExecutePostContactCreate)
  )
);
</code></pre>

<p>That magic number 40 in the plugin registration appears to correspond to the "pipeline stages" documented at <a href="https://msdn.microsoft.com/en-gb/library/gg327941.aspx" rel="noreferrer">https://msdn.microsoft.com/en-gb/library/gg327941.aspx</a>, which says</p>

<blockquote>
  <p>Post-Event</p>
  
  <p>Post-operation</p>
  
  <p>40</p>
  
  <p>Stage in the pipeline for plug-ins which are to execute after the main operation. Plug-ins registered in this stage are executed within the database transaction.</p>
</blockquote>

<p>So I've got registration XML generated by the tool that clearly says  <strong>PostOutsideTransaction</strong>, and C# code generated by the same tool that specifies stage 40, which is "executed <strong>within the database transaction</strong>"</p>

<p>So which is it? Is the XML registration syntax using a misleading name, or is this a bug in the plugin creation tool, or is the execution pipeline doing something clever that I don't understand?</p>