I have to insert empty strings in a non-nullable varchar field in an oracle db. The property of the object I'm trying to save is set to empty string, but when I call SaveChanges I get an error because EF converts my empty string to null. I know that, in code-first approach, there you can use ConvertEmptyStringToNull=false: is there a way to achieve the same behavior with database-first approach?
1 Answer
It appears that in Oracle (at least for now) the empty string is treated as null. Therefore there is no way to save an empty string in a varchar field.
Note:Oracle Database currently treats a character value with a length of zero as null. However, this may not continue to be true in future releases, and Oracle recommends that you do not treat empty strings the same as nulls.
1 Comment
Julien Debache
Has anyone looked into a workaround for this ? Ideally one which doesn't involve modifying the model or the context to become Oracle specific... I looked into
SaveChangesInterceptor and IMaterializingInterceptor but it seems that solutions like this would come with a significant performance cost.