title: "Specified cast is not valid" error when saving LINQ-To-SQL entity
body: <p>App Details:
  C#, ASP.NET MVC, SQL Server 2008 ( Same version &amp; SP level), Linq-To-SQL ORM</p>
  
  <p>I'm trying to diagnose an exception I'm receiving:</p>
  
  <blockquote>
    <p>"Specified cast is not valid."
    at System.Data.Linq.IdentityManager.StandardIdentityManager.SingleKeyManage`2.TryCreateKeyFromValues(Object[] values, V&amp; v)<br>
    at System.Data.Linq.IdentityManager.StandardIdentityManager.IdentityCache`2.Find(Object[] keyValues)<br>
    at System.Data.Linq.IdentityManager.StandardIdentityManager.Find(MetaType type, Object[] keyValues)<br>
    at System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues)<br>
    at System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance)<br>
    at System.Data.Linq.ChangeProcessor.BuildEdgeMaps()<br>
    at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)<br>
    at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)<br>
    at System.Data.Linq.DataContext.SubmitChanges()<br>
    at Repository.Save()
    at etc....</p>
  </blockquote>
  
  <p>The problem is that this is occurring only on our servers, not on our local development boxes.  I've tracked it down to a single property we're modifying:</p>
  
  <pre><code>event.SalesForceId = "701Q0000000AOTIIA4";
  </code></pre>
  
  <p>If I comment out that line, everything works fine.  </p>
  
  <p>I've tried:</p>
  
  <p>1 ) waxing all of the code on the server and redeploying. Same issue.<br>
  2 ) Pulling down a copy of the server DB and trying it locally.  Works fine.<br>
  3 ) Trying another IIS environment we have setup on the same box.  Same issue.<br>
  4 ) Physically comparing ( using AdeptSQL ) both local and remote schemas.  No differences.<br>
  5 ) Verifying the datatypes of both columns ( local and remote ) are the same.  Also, this column is a FK to another table.  I verified that both are of the same data type, down to the collation.</p>
  
  <p>The server is Windows Server 2008 and the local box is Windows 7 x64. Both have all important updates setup.  </p>
  
  <p>The only thing I can think of is perhaps since the database and web server are on different boxes that could be an issue?  Otherwise, I'm completely stumped.</p>
  
  <p>Any ideas?</p>