title: Context.CurrentMiningModel returns null in UDF
body: <p>I migrated Mining Structures from a 2008 server to a 2012 server. When I try my CLR UDF (which is working fine on SQL server 2008) in a DMX query on the 2012 server, I am getting this error:</p>
  
  <blockquote>
    <p>Exception has been thrown by the target of an invocation. Object reference not set to an instance of an object.</p>
  </blockquote>
  
  <p>My original goal was to get the <a href="http://msdn.microsoft.com/en-us/library/microsoft.analysisservices.adomdserver.context.currentminingmodel%28v=sql.110%29.Aspx" rel="nofollow">GetNodeDescription(...)</a> method running. While debugging the problem, I could isolate the problem to this UDF which fails on my SQL server 2012</p>
  
  <pre><code>[SafeToPrepare(true)]
  public static string test()
  {
    return Context.CurrentMiningModel.Name;
  }
  </code></pre>
  
  <p>My guess is that <code>CurrentMiningModel</code> is null because the following code works fine</p>
  
  <pre><code>[SafeToPrepare(true)]
  public static string testUser()
  {
   return Context.CurrentConnection.User.Name;
  }
  </code></pre>
  
  <p>Any Idea on how to solve this?
  Is somebody out there who can reproduce this?</p>
  
  <p>Thanks.</p>
  
  <p>Jan</p>
  
  <p>UPDATE:
  A contact at Microsoft confirmed this behaviour as desired due to a "Metadata-Refactoring" (whatever this means...). However, the <a href="http://msdn.microsoft.com/en-us/library/microsoft.analysisservices.adomdserver.context.currentminingmodel%28v=sql.110%29.Aspx" rel="nofollow">website</a> still pends to be updated appropiately.</p>