title: MVC 5 - An item with the same key has already been added
body: <p>I realize there are many questions about this issue. But I have yet been able to resolve this, after spending many hours trying to track this down.</p>
  
  <p>My model looks as follows:</p>
  
  <pre><code>public class Guide
      {
          public int GuideId { get; set; }
          public int GuideTypeId { get; set; }
  
          [Required(ErrorMessage = "Please enter a business name")]
          [StringLength(80, ErrorMessage="The Business Name cannot exceed 80 characters")]
          public string BusinessName { get; set; }
  
          public System.DateTime? ActiveStartDate { get; set; }
          public System.DateTime? ActiveEndDate { get; set; }
  
          [DataType(DataType.Url, ErrorMessage="The website url entered is not a valid url")]
          [StringLength(80, ErrorMessage = "The Website Url cannot exceed 80 characters")]
          public string WebsiteURL { get; set; }
  
          [Required(ErrorMessage = "Please enter a your primary location")]
          [StringLength(80, ErrorMessage = "The Primary Location cannot exceed 80 characters")]
          public string BaseLocation { get; set; }
  
          [DataType(DataType.EmailAddress, ErrorMessage = "The email address entered is not a valid email address")]
          [Required(ErrorMessage="Please enter a contact email address")]
          [StringLength(80, ErrorMessage = "The Email Address cannot exceed 80 characters")]
          public string EmailAddress { get; set; }
  
          [DataType(DataType.PhoneNumber, ErrorMessage = "The phone number entered is not a valid phone number")]
          [StringLength(20, ErrorMessage = "The Phone Number cannot exceed 20 characters")]
          public string PhoneNumber { get; set; }
  
          [Required(ErrorMessage = "Please enter a description of your fees")]
          public string FeesDescription { get; set; }
  
          public string VehiclesAvailable { get; set; }
          public string AdditionalInformation { get; set; }
          public string AccountName { get; set; }
          public string Countries { get; set; }
          public string NearestCities { get; set; }
          public string Locations { get; set; }
          public byte[] ProfileImage { get; set; }
          public bool Approved { get; set; }
          public System.DateTimeOffset LastModifiedTime { get; set; }
  
          // These four properties are here so we can display all tour types, durations, languages and currencies in a checkbox layout on the page. These are not
          // what the guide actually supports. These just represent all possible values.
          public List&lt;TourType&gt;     TourTypeList { get; set; }
          public List&lt;TourDuration&gt; TourDurationList { get; set; }
          public List&lt;TourLanguage&gt; TourLanguageList { get; set; }
          public List&lt;TourCurrency&gt; TourCurrencyList { get; set; }
  
          // These four properties represent what the guide does actually support
          public virtual List&lt;GuideTourType&gt;     GuideTourType { get; set; }
          public virtual List&lt;GuideTourDuration&gt; GuideTourDuration { get; set; }
          public virtual List&lt;GuideTourLanguage&gt; GuideTourLanguage { get; set; }
          public virtual List&lt;GuideTourCurrency&gt; GuideTourCurrency { get; set; }
  
          public bool HasImage
          {
              get
              {
                  return ProfileImage.Length &gt; 0;
              }
          }
  
          public virtual GuideType GuideType { get; set; }
      }
  </code></pre>
  
  <p>I did find someone who attempted to debug this using the following binding code:</p>
  
  <pre><code>public class DebugModelBinder : DefaultModelBinder, IModelBinder
      {
          public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
          {
              Dictionary&lt;string, ModelMetadata&gt; d = new Dictionary&lt;string, ModelMetadata&gt;(StringComparer.OrdinalIgnoreCase);
              foreach (var p in bindingContext.ModelMetadata.Properties)
              {
                  var propertyName = p.PropertyName;
                  try
                  {
                      d.Add(propertyName, null);
                  }
                  catch (ArgumentException ex)
                  {
                      throw new ArgumentException(String.Format("The Item {0} as already been added", propertyName), ex);
                  }
              }
              return base.BindModel(controllerContext, bindingContext);
          }
      }
  </code></pre>
  
  <p>I was able to get this code to work, but the exception is occuring when this line of code is executed:</p>
  
  <pre><code>return base.BindModel(controllerContext, bindingContext);
  </code></pre>
  
  <p>So it's happening in the base class. </p>
  
  <p>This exception is being generated whenI do a post on a form in an MVC 5 page. My C# controller method is never actually getting called. The error is occurring in the binding, and I have no idea what property is getting added twice. Nor do I know how to find out.</p>
  
  <p>If you need more information, I'll be glad to provide it. I've wasted several hours on this.</p>