title: Convert Enum From String To Int In DB Then Back To String - Entity Framework Core 3
body: <p>I have an Enum similar to this:</p>
  
  <pre><code>    public enum Type
      {
          TypeA,
          TypeB,
          TypeC
      }
  </code></pre>
  
  <p>I have this using Fluent API and Entity Framework 3.0:</p>
  
  <pre><code>    builder.Entity&lt;Element&gt;()
          .Property(p =&gt; p.Type)
          .HasConversion&lt;int&gt;();
  </code></pre>
  
  <p>This converts the string coming in and saves it in the DB as an int. However, when I do a query to pull it out of the DB it is staying an int.</p>
  
  <p>I have read the docs but I cannot seem to understand:</p>
  
  <p>How do I take the string of the Enum - convert it to an int for the DB - then receive a string when I query the DB?</p>
  
  <p>I thought maybe it was using EnumToNumberConverter but it takes two arguments and I have no idea what the second argument should be. As seen in these docs: <a href="https://docs.microsoft.com/en-us/ef/core/modeling/value-conversions" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/ef/core/modeling/value-conversions</a></p>
  
  <p>Can anyone please give me a concrete example of how I convert an Enum's string to integer when storing in the DB and then when querying it get handed the Enum's string again?</p>
  
  <p>Thank you.</p>