title: Dynamic in MVC Views with similar but not the same classes as Model
body: <p>Let's say we have an ASP.NET MVC View like this:</p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;dynamic&gt;" %&gt;
  &lt;%: Html.EditorFor(model =&gt; model.ServiceDate) %&gt;
  &lt;%: Html.ValidationMessageFor(model =&gt; model.ServiceDate, "*")%&gt;
  </code></pre>
  
  <p>and we have Model classes that are similar but not exactly the same, for instance <code>Invoice</code> and <code>Quote</code>, which both contain the <code>ServiceDate</code> property. Those two classes do not inherit from the same base class, actually they have no base class currently.</p>
  
  <ol>
  <li><p>How can I get them to inherit from the same base class when those two are generated by EF? If I would be able to do that, I could replace the <code>dynamic</code> and specify the base class as the View's strong type.</p></li>
  <li><p>I was under impression that this was the case that <code>dynamic</code> was built for. But obviously it does not work because there's an exception that's apparently coming from LINQ to EF:</p>
  
  <p>CS1963: An expression tree may not contain a dynamic operation</p></li>
  </ol>
  
  <p>Although it does say in the VS 2010 editor that expression will be resolved at runtime, it is not, but fails in error.</p>