Entity Framework Code First - Two tables, same concept, but different types

I have a database with two tables, one with a column numeric (19,4) and other with float. I need to map (in Entity Framework 5 Code First) this two tables in entities that have the same type, such as decimal. Change the database is the best solution, although is out of question. Anyone?

Answers


Entity Framework does not support such simple mappings (yet?) that require type conversions. It is on a feature request list but apparently not decided until now if simple type mappings will get better support in the future:

http://data.uservoice.com/forums/72025-entity-framework-feature-suggestions/suggestions/2639292-support-for-simple-type-mapping-or-mapped-type-con

A workaround is to use two properties in your model, one that is not mapped to a database column and one with a type matching the actual type in the database, and then to perform the type conversion between the two properties in their getters and setters. An example for this is here:

http://stackoverflow.com/a/14221906/270591


Need Your Help

Share an image to specific apps

android eclipse android-image

I want to show a dialog with specific apps list and want to share my picture along with text message.

sql query for multi valued attributes

sql oracle

I have resources each represented by a guid and they have attribute name-value pairs. I would like to query