title: Typeconverter does not work in asp.net core
body: <p>I have <code>Amount</code> stored in the database as <code>decimal</code>. I want to show that value on UI with thousand separator. I can add <code>[DisplayFormat(DataFormatString = "{0:N2}", ApplyFormatInEditMode = true)]</code> attribute on amount property and that would display number with thousand separator however when i POST the value back to server, the MVC model binding would not work because of commas.  </p>
  
  <p>I have created a custom type converter that converts from <code>decimal</code> to <code>string</code> and then <code>string</code> to <code>decimal</code></p>
  
  <pre class="lang-cs prettyprint-override"><code>public class NumberConverter : TypeConverter
  {
      public override bool CanConvertFrom(
          ITypeDescriptorContext context,
          Type sourceType)
      {
          if (sourceType == typeof(decimal))
          {
              return true;
          }
          return base.CanConvertFrom(context, sourceType);
      }
      public override object ConvertFrom(ITypeDescriptorContext context,
          CultureInfo culture, object value)
      {
          if (value is decimal)
          {
              return string.Format("{0:N2}", value);
          }
          return base.ConvertFrom(context, culture, value);
      }
      public override bool CanConvertTo(ITypeDescriptorContext context,
          Type destinationType)
      {
          if (destinationType == typeof(decimal))
          {
              return true;
          }
          return base.CanConvertTo(context, destinationType);
      }
      public override object ConvertTo(ITypeDescriptorContext context,
          CultureInfo culture, object value, Type destinationType)
      {
          if (destinationType == typeof(decimal) &amp;&amp; value is string)
          {
              return Scrub(value.ToString());
          }
          return base.ConvertTo(context, culture, value, destinationType);
      }
  
      private decimal Scrub(string modelValue)
      {
          NumberStyles _currencyStyle = NumberStyles.Currency;
          CultureInfo _culture = new CultureInfo("en-US");
  
          var modelDecimal = 0M;
          decimal.TryParse(
             modelValue,
             _currencyStyle,
             _culture,
             out modelDecimal
         );
  
          return modelDecimal;
      }
  }
  </code></pre>
  
  <p>and then i applied it on one of the model property. Note that model may have other decimal properties which may not required this conversion.</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class MyModel
  {
  
      [TypeConverter(typeof(NumberConverter))]
      [Display(Name = "Enter Amount")]
      public decimal Amount { get; set;}
  
      public string Name { get; set; }
  }
  </code></pre>
  
  <p><strong>Index.cshtml</strong></p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form asp-action="submit" asp-controller="home"&gt;
      @Html.EditorFor(m =&gt; m.Amount)
      &lt;button type="submit" class="btn btn-primary"&gt;Save&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>However the converter code never gets fired. When i put break point in <code>NumberConverter</code> none of the break point hit. Do i need to register type converter anywhere? I am using asp.net core.   </p>