msawczyn/EFDesigner

Decimal Field Default Value not allow 0m

dongjason opened this issue · 2 comments

For properties of Decimal type, when I set the initial value to 0, the migration reports an error because it could not set the default value of 0, it expect it to be a literal of 0m. But I could not put 0m in the designer because it think it is not a valid numeric value.

Hi @dongjason

I'm not quite sure I understand the issue. A property with a Decimal type, and an initial value of 0 in the designer, generates (extra code eliminated for readability)

    public class AnEntity
    {
        public AnEntity()
        {
            Property1 = 0;
        }

        public long Id { get; set; }
        public decimal Property1 { get; set; }
    }

That's perfectly valid C# and compiles without issue. Are you seeing something different?