EF Core Nullable Foreign Key Relationship
I have this one to many
FK relationship configuration in EF Core that I want to be nullable. If I set the type of ClientId to be nullable (which is a custom class that wraps up a Guid value which the entire codebase uses), EF Core will complain about:with the generated pre-compilation query being:
EF Core is doing a ternary conditional operation and is initializing
Identifier to its default constant value when not set, which is causing this issue. I don't know how to instruct it not to do that.Right now I cannot mess with the custom
Identifier? class so using Guid? instead is not an ideal option. Using IsRequired(false) instead of Nullable<> also brought no results. I have also tried this converter:to no avail, even with a nullable version.