title: use entity-framework to map int column to enum property
body: <p>I have a enum type called <code>Operation</code> like this:</p>
  
  <pre><code>[Flags]
  public enum Operation
  {
      None = 0,
      View = (1 &lt;&lt; 0),
      Add = (1 &lt;&lt; 1),
      Edit = (1 &lt;&lt; 2),
      Delete = (1 &lt;&lt; 3),
      ReservedA = (1 &lt;&lt; 4),
      ReservedB = (1 &lt;&lt; 5),
      Admin = (View | Add | Edit | Delete)
  }
  </code></pre>
  
  <p>and table <code>permission</code> contains a <code>operations</code> column. This table maps to a class like this:</p>
  
  <pre><code>[Table("rolepermission")]
  public class Permission : IComparable
  {
      private int _id = 0;
  
      private Operation _operations = Operation.None;
  
      private List&lt;UserRole&gt; _roles = null;
  
      public Permission()
      {
          _roles = new List&lt;UserRole&gt;();
      }
  
      [Key]
      public int Id
      {
          get { return _id; }
          set { _id = value; }
      }
  
      [EnumDataType(typeof(Operation))]
      public Operation Operations
      {
          get { return _operations; }
          set { _operations = value; }
      }
  }
  </code></pre>
  
  <p>but it doesn't work.</p>
  
  <p>Is there any elegant way that can map it?</p>
  
  <p>I think creating an <code>int</code>-type property is not the best way.</p>