Default Values

Feb 28, 2015 at 7:57 PM
Is there any way to configure default values for entities?

Feb 28, 2015 at 8:23 PM
do you mean defaults for columns in DB? - these are supported, but I would not recommend using them unless you have to... they are quite tricky... If you mean defaults for property values in new entities - it is always null or default value for type (0). I recommend creating extension methods for creating new entities (see BookExtensions.cs in example) NewBook method - these serve as constructors for entities. Inside this method you can set (default) values for properties explicitly, and never worry about them anymore
Mar 1, 2015 at 5:01 PM
I mean default database values, like all the int's and decimal can have 0 as default for cases when records are inserted using external sources

Mar 1, 2015 at 5:14 PM
Use Column attribute on property, with Default value assigned - just a string:

int Foo {get;set;}

Although again, I found using the defaults to be quite tricky, even with MS SQL, mostly when it comes to updating db schema. So you might into some bumps there.