Showing posts with label Entity Framework. Show all posts
Showing posts with label Entity Framework. Show all posts

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.