title: Adding Validation Attributes With an Entity Framework Data Model
body: <p><strong>Preface Feb 2015</strong> If you are still using Entity Framework EDMX, please do yourself a favor and checkout using Entity Framework Code First instead. The difference is that your tables are created from your model classes, rather than in EDMX where your model classes are created with your tables. It's an all around easier solution, and the problem in this question doesn't even exist!</p>
  
  <p><a href="http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application">Getting Started with Entity Framework 6 Code First using MVC 5</a></p>
  
  <p>I have an existing SQL database, and I am using ADO.NET Enity Data Model for the model. I am trying to build some CRUD features into my MVC application.</p>
  
  <p>In all the tutorials I have found on the subject, they build the model from scratch and add the attributes to the model class. For example:</p>
  
  <pre><code>    [Required]
      [StringLength(10)]
      public string Name { get; set; }
  </code></pre>
  
  <p>However, the model classes are auto-generated, so I think changing them is a bad idea (and will get written over anyway if the the database model is refreshed).</p>
  
  <p>How would I add validation attributes? </p>