title: Setting thread Culture to a neutral culture
body: <p>When try to save data to database with <code>db_ent.SaveChanges()</code> I have this error:</p>
  
  <blockquote>
    <p>Culture 'sr' is a neutral culture. It cannot be used in formatting and parsing and therefore cannot be set as the thread's current culture. Any solutions for this?</p>
  </blockquote>
  
  <p>Edit:</p>
  
  <p>My RouteLocalization Helper</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using System.Web.Routing;
  using System.Threading;
  using System.Globalization;
  
  namespace darns.Helpers
  {
  public class MultiCultureMvcRouteHandler : MvcRouteHandler
  {
      protected override IHttpHandler GetHttpHandler(System.Web.Routing.RequestContext requestContext)
      {
          String culture = requestContext.RouteData.Values["culture"].ToString();
          var ci = new CultureInfo(culture);
          Thread.CurrentThread.CurrentUICulture = ci;
          Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name);
          return base.GetHttpHandler(requestContext);
      }
  }
  
  public class SingleCultureMvcRouteHandler : MvcRouteHandler {}
  
  public class CultureConstraint : IRouteConstraint
  {
      private string[] _values;
      public CultureConstraint(params string[] values)
      {
          this._values = values;
      }
  
      public bool Match(HttpContextBase httpContext,Route route,string parameterName,
                      RouteValueDictionary values, RouteDirection routeDirection)
      {
          // Get the value called "parameterName" from the 
          // RouteValueDictionary called "value"
          string value = values[parameterName].ToString();
          // Return true is the list of allowed values contains 
          // this value.
          return _values.Contains(value);
      }
  }
  
  public enum Culture
  {       
      sr = 1,
      hr = 2,
      en = 3,
      ru = 4
  }
  
  /// &lt;summary&gt;
  /// Util class for storing error message pairs
  /// &lt;/summary&gt;
  /// &lt;typeparam name="E"&gt;&lt;/typeparam&gt;
  /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt;
  public class ErrorPair&lt;E, T&gt;
  {
      public E Key { get; set; }
      public T Message { get; set; }
      public ErrorPair(E key, T message)
      {
          Key = key;
          Message = message;
      }
  }
  }
  </code></pre>