Saturday, April 21, 2012

"Can not insert NULL into column" when SaveChanges in Entity Framework

It is a strange error as the value is obviously set in the POCO used. The reason is the model created marked the column as 'Identity', which causes EF to insert a NULL and try to get the value back from database. If you use SQL Profiler, you can see the behavior clearly.

No comments: