Reputation: 2301
I am having this problem intermittently with ServiceStack.Net OrmLite on SqLite.
My model class is using a Guid for the primary Id. My code sets a Guid.NewGuid() value to my model before saving, if the model is new.
I have set a breakpoint to verify that immediately before db.Save(myModel), myModel.Id is always a populated, unique Guid. However, the value committed to the table is NULL.
It seems after I create the database, it saves a the values correctly for a while, but then just starts saving NULLs for the Id! My code is doing the same thing throughout. This seems especially extraordinary to me, since OrmLite creates the column as a non-Nullable primary key.
Has anybody seen this issue, or know what might be causing it? Thank you.
Upvotes: 1
Views: 960
Reputation: 2301
This was caused by having an [AutoIncrement] attribute on the Guid Id. Oops!
Upvotes: 2