Is there any way that can I set default value as Empty.string in Model.
I have a column Name in the Model its not null field in the database with default value is Empty.string
is there any way that I can set this default property in the Model for this column?
Thanks
There is a setting for this which you can configure by overriding the default model binder as follows:
then configure this as the default model binder in application start in the global.asax:
and there you go, no more null strings.
A cleaner alternative is to provide a custom ModelMetadataProvider instead of creating a ModelBinder which modifies the ModelMetadata.
Then in Application_Start()