yyy
yyy

Reputation: 425

Entity Framework Decimal Inconsistency

I'm implementing the tutorial http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/accessing-your-model's-data-from-a-controller

I use Entity Framework 4.1. In the database decimal value is mapped (18,2). In the creating form I entered 1000 but in the details page the decimal value output is 1000,00 and also in the edit page as well. I use @Html.EditorFor(model => model.Price) for input and for output. When I looked at the database created by the Entity Framework the Price column which is my decimal value is created with this SQL command:

[Price] DECIMAL(18,2) NOT NULL

Why there is inconsistance?

Upvotes: 0

Views: 330

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364249

You are comparing two different things. The mapping describes the precision which can be stored in the database but it has nothing to do with the way how your ASP.NET MVC View shows decimal number - it is handled by output formatting.

Upvotes: 1

Related Questions