Hi, I have looked in the documentation and also in the forum but didn't find anything. So is it even possible with DO to set some default values on fields like:

[Field (DefaultValue(typeof(int), 100))] public int Number {get;set;}

thanks, David

This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by david_csharp.

asked Jul 05 '10 at 15:00

Editor's gravatar image


One Answer:

There is really no way to do this - at least, currently. Only "default defaults" are supported. Partially, this is because of schema upgrade layer - it's much easier to deal with defaults there.

But you can:

  • Set default in constructor (in particular, relying on reflection or any other "defaults provider" you can invent)

  • Manually update newly created columns with non-standard defaults on upgrade using UpgradeHander, if this is necessary.

answered Jul 06 '10 at 09:02

Alex%20Yakunin's gravatar image

Alex Yakunin

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview


Once you sign in you will be able to subscribe for any updates here



Asked: Jul 05 '10 at 15:00

Seen: 2,959 times

Last updated: Jul 05 '10 at 15:00

powered by OSQA