String Or Binary Data Would Be Truncated
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.
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.