I've recently been working on a project using Umbraco v10.4.2, and I'm having some issues with the model builder. Specifically, I've noticed that some of the fields generated by the model builder are expecting an input even when the field is not marked as required in the back office. This issue is causing the generated .cs model to throw a "System.NullReferenceException: Object reference not set to an instance of an object." error.
I found that this error is occurring because the _publishedValueFallback property is staying null for the fields that are not marked as required. This is causing issues when the model is generated and the code tries to access these fields.
I'm wondering if anyone else has experienced this issue and if there are any workarounds or fixes that can be implemented. I've tried looking through the Umbraco documentation and forum, but I haven't been able to find a solution yet.
Model Builder: Non-Required Fields Expecting Input and Causing Null Reference Exception
Hi everyone,
I've recently been working on a project using Umbraco v10.4.2, and I'm having some issues with the model builder. Specifically, I've noticed that some of the fields generated by the model builder are expecting an input even when the field is not marked as required in the back office. This issue is causing the generated .cs model to throw a "System.NullReferenceException: Object reference not set to an instance of an object." error.
I found that this error is occurring because the _publishedValueFallback property is staying null for the fields that are not marked as required. This is causing issues when the model is generated and the code tries to access these fields.
I'm wondering if anyone else has experienced this issue and if there are any workarounds or fixes that can be implemented. I've tried looking through the Umbraco documentation and forum, but I haven't been able to find a solution yet.
Most of the times weird issues like this are caused by the code calling the property. Can you paste a snipped of the code that refers to this model?
is working on a reply...