title: Entity Framework: Get Entity Associated with DbCommandTree
body: <p>I'm trying to do some work with the <code>EFProviderWrapperToolkit</code>
  <a href="http://blogs.msdn.com/b/jkowalski/archive/2009/06/11/tracing-and-caching-in-entity-framework-available-on-msdn-code-gallery.aspx" rel="nofollow">http://blogs.msdn.com/b/jkowalski/archive/2009/06/11/tracing-and-caching-in-entity-framework-available-on-msdn-code-gallery.aspx</a></p>
  
  <p>In my derived <code>DbCommandWrapper</code>, is there any way to get the associated entity in the <code>ObjectStateManager</code> if the <code>DbCommandTree</code> in question is a <code>DbModificationCommandTree</code>? </p>
  
  <p>Basically, I want to do something like:</p>
  
  <pre><code>if (base.Definition.CommandTree is DbModificationCommandTree)
  {
     var targetEntity = ((DbModificationCommandTree)base.Definition.CommandTree).TargetEntity; 
  }
  </code></pre>