Andrew Bancroft 3/29/2017

Entity Framework Tip – Specifying Decimal Precision

Read Original

This article provides a quick tip for Entity Framework developers on how to specify custom decimal precision and scale for properties mapped to SQL Server. By default, Entity Framework maps .NET decimal types to decimal(18,2), which can truncate values with higher precision. The article explains how to override the OnModelCreating method in your DbContext and use the HasPrecision() method to set the desired precision and scale, ensuring accurate storage of decimal values without truncation.

Entity Framework Tip – Specifying Decimal Precision

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet