title: EF Exception: String or binary data would be truncated. The statement has been terminated.?
body: <p>I have read many posts related to this issue, but couldn't find an answer.
  I am trying to load a large amount of data from Excel into SQL Server.
  Thousands of records. And I am getting this exception:</p>
  
  <blockquote>
    <p>String or binary data would be truncated. The statement has been
    terminated.</p>
  </blockquote>
  
  <p>Obviously some values exceed the field size in the database.
  The error comes from SQL Server AFIK.</p>
  
  <hr>
  
  <p><strong>My question - How could I possibly know what record and what field value caused this?</strong></p>
  
  <p>There are no specific details in EF exception, except the one I mentioned.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Some asked for the code fragment, but it's actually very simple, the problem is not with the code:</p>
  
  <pre><code>// employees is a List&lt;Employee&gt; collection loaded from Excel
  using (var context = new Entities())
  {
      employees.ForEach(e =&gt; context.Employee.AddObject(e));
      context.SaveChanges();
  }
  </code></pre>
  
  <p>Also the suggested approach to use <strong>DbEntityValidationException</strong> (which is only available in Entity Framework 5.0) is not working, the <strong>catch</strong> block didn't catch the exception.</p>
  
  <pre><code>try
  {
      ImportData();
  }
  catch (DbEntityValidationException ex)
  {
      foreach (var item in ex.EntityValidationErrors)
      {
          //...
      }
  }
  </code></pre>
  
  <p><strong>The only solution that I found</strong> so far is to use SQL Server Profiler, and define the following events to monitor:</p>
  
  <p><img src="https://i.stack.imgur.com/mxJud.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/zfEu3.png" alt="enter image description here"></p>
  
  <p>Now I can see the Email is too long.</p>