Decimal Field Default Value not allow 0m
dongjason opened this issue · 2 comments
dongjason commented
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.
msawczyn commented
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?
dongjason commented
Michael,
Sorry I was side tracked and did not get back to you sooner.
The error was occurring on the generated migration for Migration.AlterColumn statement with defaultvalue: 0 for the decimal fields. What is interesting is now it suddenly generates the Migration.AlterColumn statement with defaultvalue: 0m.
I don’t recall I did anything that could lead to that change. I will keep an eye out for it. Hopefully it will stay good.
Thanks a lot.
Jason
From: Michael Sawczyn<mailto:notifications@github.com>
Sent: Saturday, February 13, 2021 9:49 AM
To: msawczyn/EFDesigner<mailto:EFDesigner@noreply.github.com>
Cc: dongjason<mailto:dong_jason@hotmail.com>; Mention<mailto:mention@noreply.github.com>
Subject: Re: [msawczyn/EFDesigner] Decimal Field Default Value not allow 0m (#268)
Hi @dongjason<https://github.com/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?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#268 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACA4563TKW3YNQBFJ7N4RM3S62GPTANCNFSM4XLJBTEQ>.