The float datatype is converted to a double by Entity Framework.

asp.net-mvc-3 entity-framework

Question

I am working on an asp.net mvc 3 web application using database-first approach.

I have a table called Results that contains two columns (min & max) of type float, but when I use the Entity Framework to map the existing database into model classes, then EF creates a class Results with the data type of the min & max fields as double instead of float as specified in the exsiting database.

So why is this behaviour happening? Will it cause any problems?

1
15
4/24/2012 6:51:24 AM

Accepted Answer

This is normal behaviour, as per MSDN.

Even SQL-server's real datatype is mapped to double, even though float would definitely be enough there.

But the type names are very confusing here. In fact float (t-SQL) is the same as double (.Net): a precision of 15 digits and a range of negative 1.79769313486232e308 to positive 1.79769313486232e308.

19
4/24/2012 3:24:47 PM

Popular Answer

I'm not sure if your problem is identical to this or not:

http://forums.asp.net/p/1606916/4100117.aspx

But it doesn't seem like this should cause any problems. You could lose precision with your numbers going from a double to a float, but it should still work unless you need the extra digits.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow