title: Automatically pre-generate views in entity framework
body: <p>[I'm updating the title to reflect the answer I found, but leaving the question text unaltered]</p>
  
  <p>This is basically the same question as <a href="https://stackoverflow.com/questions/2042344/how-to-output-namespace-in-t4-templates">How to output namespace in T4 templates?</a>, but all of the answers there rely on accessing the Visual Studio host.  As Brad Wilson comments in GarethJ's answer, these answers do not work in the MSBuild host via the <a href="http://www.olegsych.com/2010/04/understanding-t4-msbuild-integration/" rel="nofollow noreferrer">Visualization and Modeling SDK</a>.</p>
  
  <p>My end goal is to add pregenerated views to an edmx file.  It seems that VS has a hardcoded internal association from foo.edmx to foo.tt and foo.Context.tt.  Changes to foo.edmx do not trigger my foo.Views.tt to run its transforms, even though it is &lt;DependentUpon> foo.edmx in the project file.</p>
  
  <p>Using the V&amp;M SDK causes dependent text transforms to run when the parent changes, but all the namespaces get stripped out of the entity class files.  EF.Utility.CS.ttinclude relies on the VS host, returning a null namespace if namespaceHint is not found.
  Since I also don't want a dependency on $(DevEnvDir) in my MSBuild project, I have copied EF.Utility.CS.ttinclude to a source-controlled folder and am altering it to suit the MSBuild transform host.</p>
  
  <p>I want to retrieve the same string returned by <code>CallContext.LogicalGetData("NamespaceHint")</code> or by <code>Host.ResolveParameterValue("", "", "namespaceHint")</code>.  My current plan involves: passing $(RootNamespace) and $(ProjectDir) via &lt;T4ParameterValues> and retrieving them in t4 with ResolveParameterValue, then getting the .tt file's directory relative to ProjectDir and converting slashes to periods, then concatenating onto RootNamespace.  Ugly but in theory it will work.</p>
  
  <p>I'm looking for one of the following:</p>
  
  <ul>
  <li>A method to retrieve the same value as Visual Studio's NamespaceHint through the V&amp;M SDK, more simply than the concatenation described above.</li>
  <li>A method for setting up the proper dependency between foo.edmx and foo.arbitrary.tt without using the V&amp;M SDK</li>
  <li>A method for excluding foo.tt and foo.Context.tt from being processed by the V&amp;M SDK while still being processed by VS's built-in entity framework tools.</li>
  </ul>
  
  <p>Either of latter would be slightly preferable to the former, but so far my research indicates that they are not possible.  My current approach runs text transformation twice: VS does hardcoded edmx processing, then V&amp;M SDK does the generic tt processing.  If I get a really good answer for either of those, I will change the question title for posterity.</p>
  
  <p>This question is also similar to: <a href="https://stackoverflow.com/questions/8997442/getting-the-namespace-for-an-edmx-in-a-t4-template">Getting the namespace for an edmx in a T4 template</a></p>