The question is, as in the title, does the MVC middleware allow private constructors for view model objects. Apparently, this is not so MissingMethodException: No parameterless constructor defined for this object., even if there is a private constructor without parameters. If the use of a private constructor is allowed, is there a workaround for the architecture?
Such a constructor can be useful to ensure that only object-objects-objects can create ViewModel objects whose fields cannot be sequentially filled - there would be no chance that in other parts of the code some fields will be forgotten to complete.
Entity Framework can use private constructors and private properties in a similar situation.
source
share