1

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 1

2

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.

Source

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.