title: XML error: Value was either too large or too small for an unsigned byte
body: <p>I'm totally green to this and it's driving me nuts - it works for some data sets but not for others. </p>
  
  <p>EDIT: It's looking like it's related to the number of records - somehow when teh number of records reaches a certain amount - maybe something like 250 - that's when it crashes the XML. Somehow the auto-incrementing ID primary key seems to be involved because I can see that when I add even 3 records when the ID column has gone into the 400's but all records are deleted it's still producing the same error but when I reset the ID back to zero - the same 3 records can be added and properly formatted in the XML body.</p>
  
  <p>Mapping types: Int32 -> Byte System.Int32 -> System.Byte Destination path: FixtureDto.ExchangeType.ExchangeType.Id.Id Source value: 268</p>
  
  <p>Value was either too large or too small for an unsigned byte.</p>
  
  <p>The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.</p>
  
  <p><a href="https://i.stack.imgur.com/GfIy5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GfIy5.jpg" alt="enter image description here"></a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;Error&gt;
  &lt;Message&gt;An error has occurred.&lt;/Message&gt;
  &lt;ExceptionMessage&gt;
  The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.
  &lt;/ExceptionMessage&gt;
  &lt;ExceptionType&gt;System.InvalidOperationException&lt;/ExceptionType&gt;
  &lt;StackTrace/&gt;
  &lt;InnerException&gt;
  &lt;Message&gt;An error has occurred.&lt;/Message&gt;
  &lt;ExceptionMessage&gt;
  Mapping types: Int32 -&gt; Byte System.Int32 -&gt; System.Byte Destination path: FixtureDto.ExchangeType.ExchangeType.Id.Id Source value: 268
  &lt;/ExceptionMessage&gt;
  &lt;ExceptionType&gt;AutoMapper.AutoMapperMappingException&lt;/ExceptionType&gt;
  &lt;StackTrace&gt;
  at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext() at WriteArrayOfFixtureDtoToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract ) at System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter writer, Object graph) at System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content) at System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.WebHost.HttpControllerHandler.&lt;WriteBufferedResponseContentAsync&gt;d__1b.MoveNext()
  &lt;/StackTrace&gt;
  &lt;InnerException&gt;
  &lt;Message&gt;An error has occurred.&lt;/Message&gt;
  &lt;ExceptionMessage&gt;
  Value was either too large or too small for an unsigned byte.
  &lt;/ExceptionMessage&gt;
  &lt;ExceptionType&gt;System.OverflowException&lt;/ExceptionType&gt;
  &lt;StackTrace&gt;
  at System.Convert.ToByte(Int32 value) at System.Int32.System.IConvertible.ToByte(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.ComponentModel.BaseNumberConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType) at AutoMapper.Mappers.TypeConverterMapper.&lt;&gt;c__DisplayClass1_0.&lt;GetConverter&gt;b__0() at AutoMapper.Mappers.TypeConverterMapper.Map(ResolutionContext context, IMappingEngineRunner mapper) at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
  &lt;/StackTrace&gt;
  &lt;/InnerException&gt;
  &lt;/InnerException&gt;
  &lt;/Error&gt;</code></pre>
  </div>
  </div>
  </p>