I have a situation, consider:
Application is running OK.
When app starts, if table T1 is empty (0 records), SqlBulkCopy is used to insert 5000 records in T1 allowing triggers to fire and constraints check, the result is:
I have tried to initialize the context but no success.
The procedure will succeed in two cases:
What could cause the StackOverflow exception.
Ok, problem solved, just in case someone else would face a similar error, I will share my solution.
I have modified the T4 template to enable the EDM to produce entities from my database that:
Implement the INotifyPropertyChanged.
Apply Data Validation by implementing the INotifyDataErrorInfo and using DataAnnotations by checking validation rules in Metadata separate class.
That caused the StackOverFlow excepetion.
Disabling the Property Validation solved the problem.
So, Data Validation is not welcomed as SqlBulkCopy while WriteToServer is in progress.