title: MaxLength Attribute in EF4.3.1
body: <pre><code> The type 'System.ComponentModel.DataAnnotations.MaxLengthAttribute' 
   exists in both 
  
   [path...]\packages\EntityFramework.4.3.1\lib\net40\EntityFramework.dll 
  
   and
  
  'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework
  \.NETFramework\v4.5\System.ComponentModel.DataAnnotations.dll'  
  </code></pre>
  
  <p>Now, I have read <a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/fab7a591-f790-4064-aeb5-c320eb5057e5" rel="noreferrer">on msdn</a> that its safe to exclude the EntityFramework reference (which was added through the nuget package). However, when I do that, I cant create a DBContext properly as the DbModelBuilder class lives in the EntityFramework dll. Also, some other critical classes are missing when I remove the EntityFramework refference so this is old and irrelevant solution now.</p>
  
  <p><strong>Update (disambiguation)</strong>: Both <code>System.ComponentModel.DataAnnotations.dll</code> and <code>EntityFramework.dll</code>  include <code>System.ComponentModel.DataAnnotations.MaxLengthAttribute</code>. The problem is that each dll also includes other classes that are critical to EF code-first design. For example:</p>
  
  <pre><code>EntityFramework.dll:
   - System.Data.Entity.DbModelBuilder
  
  System.ComponentModel.DataAnnotations.dll:
   - System.ComponentModel.DataAnnotations.RegularExpressionAttribute
  </code></pre>