edmx - Cannot insert NULL into a non-identity column in Entity Framework. Funny thing... it's not null? -


i have salesorder table columns id , orderid. id auto-generated int. orderid non-nullable string max length of 20, , use store customer's order number reference.

after adding new salesorder , calling savechanges, following error:

cannot insert value null column 'orderid', table 'salesorder'; column not allow nulls. insert fails. statement has been terminated.

problem is, object i'm saving does have orderid! it's it's trying save entity first before saves values. how ef handles things?

my setup ef4.1, using edmx model-first approach. storegeneratedpattern set none. default value set (none) i've tried various values. entity key false, since it's not part of key. i've tried deleting salesorder entity , regenerating database.

i see code...i had similar problems when filling objects in loop saving them savechanges. thought fields populated, not.

i'd have see code executes before save changes before can offer helpful.

if problem mine , calling savechanges after using iterator populate objects, can find bad data moving savechanges iterator called each iteration...but hypothetical guesswork without seeing code...


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -