I’m using Entity Framework Code-First with POCOs for my database interaction. I have a field that is optional called “Title”.
When I get the object from the form, the default model binder automagically makes “Title” null instead of empty.
How do I get the model binder to return an empty string instead of null?
Thanks for any help
You are requesting non-standard behaviour, so you need non-standard solution.
Extend default model binder, override its CreateModel method – do what you want for specific cases, and return base.CreateModel for others.
Dont forget to register it as default model binder at application start.