Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data Type for Currency in Entity Framework

What data type should I use to hold currency values in Entity Framework 6 and what data type should I map it in SQL Server 2012?

Thank You, Miguel

like image 203
Miguel Moura Avatar asked Oct 23 '25 17:10

Miguel Moura


1 Answers

To have precise values, use decimal in C#, and also decimal(m, n) in SQL Server. float or double or real just aren't precise and will be susceptible to rounding errors - I'd avoid those.

See this other SO question (and its answers) for a discussion of money vs. decimal in SQL Server and why you should avoid money in SQL Server.

like image 59
marc_s Avatar answered Oct 27 '25 01:10

marc_s



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!