title: radio button for enum
body: <p>I have a database first model, where is a Person entity, like this:</p>
  
  <pre><code>public partial class Person
  {
      public System.Guid personID { get; set; } 
      public string firstName { get; set; } 
      public string lastName { get; set; }
      public string sex { get; set; } // since in the DB it is char(1), default = 'F'
  }
  </code></pre>
  
  <p>I defined a public enum for sex selection:</p>
  
  <pre><code>public enum Sex
  {M, F}
  </code></pre>
  
  <p>which I want to use it to select the sex of the person and to render it as a radio button group.</p>
  
  <p>I followed this solution: <a href="https://stackoverflow.com/questions/5621013/pass-enum-to-html-radiobuttonfor-mvc3">pass enum to html.radiobuttonfor MVC3</a> but couldn't make it work.</p>
  
  <p>According to that answer, I added the RadioButtonForEnum extension, I extended my partial class with another property, like this:</p>
  
  <pre><code>public partial class Person
  {
      public System.Guid personID { get; set; }
      public string firstName { get; set; }
      public string lastName { get; set; }
      public string sex { get; set; } // since in the DB it is char(1), default = 'F'
      public Sex personSex { get; set; }
  }
  </code></pre>
  
  <p>and changed my viewmodel and controller to use the enum.</p>
  
  <p>Now I got the error:</p>
  
  <blockquote>
    <p>The associated metadata type for type 'MyApp.Models.Person' contains the following unknown properties or fields: personSex. Please make sure that the names of these members match the names of the properties on the main type.</p>
  </blockquote>
  
  <p>How can I fix this, since the model is derived from the database?</p>