title: Entity Framework - Azure Table Storage Provider - Enum Support
body: <p>I am actually using the Azure Storage Table provider for EF (<a href="https://www.nuget.org/packages/EntityFramework.AzureTableStorage/" rel="nofollow noreferrer">EntityFramework.AzureTableStorage 7.0.0-beta1</a>).</p>
  <p>I've ended up how to configure the DbContext:</p>
  <pre><code>public class Subscription
  {
      public string Environment { get; set; }
          
      public string Name { get; set; }
  
      ...
      ...            
  }
  
  public class EF7Context : DbContext
  {
      public DbSet&lt;Subscription&gt; Subscriptions { get; set; }
      
      protected override void OnConfiguring(DbContextOptions options)
      {
          options.UseAzureTableStorage(&quot;MyconnectionString&quot;);
      }
  
      protected override void OnModelCreating(Microsoft.Data.Entity.Metadata.ModelBuilder modelBuilder)
      {
          // Configure the Azure Table Storage
          modelBuilder.Entity&lt;Subscription&gt;()
              .ForAzureTableStorage() // Data are stored in an Azure Table Storage.
              .Table(&quot;SubscriptionDev&quot;) // Name of the Table in the Azure Storage Account
              .PartitionAndRowKey(s =&gt; s.Environment, s =&gt; s.Name); // Map the partition and the row key
      }
  }
  </code></pre>
  <p>But Now I would like to add an enum as part of the <code>Subscription</code> model.
  I've found a workaround to do this:</p>
  <p>I've got an enum :</p>
  <pre><code>public enum QueuePriority
  {
      High,
      Low
  }
  </code></pre>
  <p>I've added these properties to the <code>Subscription</code> class:</p>
  <pre><code>public int PriorityId { get; set; }
  
  public QueuePriority Priority
  {
      get { return (QueuePriority)PriorityId; }
      set { PriorityId = (int)value; }
  }
  </code></pre>
  <p>And Declare the <code>Priority</code> property as shadow in EF configuration so that I'm not going to have the PriorityId and the Priority stored both in the Azure Table :</p>
  <pre><code>protected override void OnModelCreating(Microsoft.Data.Entity.Metadata.ModelBuilder modelBuilder)
  {   
      ...
           
      // We are not mapping the Enum in the database only the IDs.
      modelBuilder.Entity&lt;Subscription&gt;().Property(s =&gt; s.Priority).Shadow();
  }
  </code></pre>
  <p>So I am wondering if there is a better way to accomplish this and/or If next versions of EF.AzureTableStorage is going to support Enum ?</p>
  <p>Thanks</p>