String Or Binary Data Would Be Truncated




String Or Binary Data Would Be Truncated, Validation Failed For One Or More Entities, The Statement Has Been Terminated, How To Fix String Or Binary Data Would Be Truncated, How To Fix Validation Failed For One Or More Entities, Sql, MSSQL, Asp.Net

Mainly this error happens in the following situation. 1. Length of data to be inserted exceeds the capacity of the field in the table. In other words, the field capacity in the table is not enough to hold the inserting data. For example, lets consider a table having column field with DataType varchar(30). If we try to insert data of length more than 30, we can get this Error.

String Or Binary Data Would Be Truncated, Validation Failed For One Or More Entities, The Statement Has Been Terminated, How To Fix String Or Binary Data Would Be Truncated, How To Fix Validation Failed For One Or More Entities, Sql, MSSQL, Asp.Net

If Entity Framework is used, we will get Validation Failed For One Or More Entities. That means if we insert huge data using Entity Framework, we can get the above error. Lets Consider how to resolve this Issue.




In order to resolve this Issue, there are two ways. First, Increase the size or length of field in the SQL table. In the above case, it was varchar(30). Increase it to varchar(MAX). Second, Trim your data to the length of the table field length. If the data is having length 35, then trim the data to length 30.

By this way we can resolve this issue.