Sep 02, 2012 10:38 PM|juliandormon|LINK
Decker Dong - MSFT
Of course it cannot be null
I appreciate your time but I think we're going around in circles here. I do not want the value to be null. I was not trying to make it null. I understand why I get the error but I do not understand why I cannot trap for this from the model level.
I thought the whole purpose of using code first and entity framework and strongly typed classes was to avoid having to write traps for my data models. I am new to EF, OO and .NET for that matter so apologize if my thinking is not correct. I was hoping that
EF would allow me to set default values for my object's parameters - that way I would not have to post hidden form values to avoid nulls or otherwise worry about this data once my model was constructed.
You suggested that my attempt to create the default in the contructor should work if I created an instance of the class. I then asked, is an instance of the class being created in the code that the scaffold generates? Perhaps an instance is not created and
therefore this is the problem. Could you answer that for me please? Thank you.