title: String or binary data would be truncated - Add new row (Entity Framework)
body: <p>I get this error when I try to add a new row.</p>
  
  <pre><code>HexStringToByteArray("0x546F206A65737420707573747920706C696B0D0A");
  </code></pre>
  
  <blockquote>
    <p>String or binary data would be truncated.\r\nThe statement has been
    terminated.</p>
  </blockquote>
  
  <pre><code>attachement.ATF_ID = 244512;
  attachement.ATF_WFDID = 160489;
  attachement.ATF_ATTID = 244512;
  attachement.ATF_Name = "teska14.txt";
  attachement.ATF_FileType = ".txt";
  attachement.ATF_Value = HexStringToByteArray("0x546F206A65737420707573747920706C696B0D0A");
  attachement.ATF_FileIsOcr = 0;
  attachement.ATF_CreatedBy = "test";
  attachement.ATF_UpdatedBy = "test";
  attachement.ATF_OrginalValueHash = HexStringToByteArray("0x4C35C01D7E10FB7F7440D39932265E7C7F09A4D17FEFB55AE9E1DDAC97AD373E");
  attachement.ATF_OrginalName = "test.txt";
  attachement.ATF_Version = -1;
  context2.WFAttachmentFiles.AddObject(attachement);
  //context.AddToWFAttachmentFiles(attachement);
  //context.WFAttachmentFiles.AddObject(attachement);
  context2.SaveChanges();
  </code></pre>
  
  <p>HEC Code:</p>
  
  <pre><code>public static byte[] HexStringToByteArray(string hexString)
  {
      if (string.IsNullOrWhiteSpace(hexString))
          throw new ArgumentNullException("hexString");
  
      if (hexString.Length % 2 != 0)
          throw new Exception("Invalid hex string");
  
      var bytes = new byte[hexString.Length / 2];
      for (int i = 2; i &lt; bytes.Length; i++)
      {
          bytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
      }
      return bytes;
  }
  </code></pre>