Search for existing suggestions

Custom type mapping and type conversion support

Currently the only conversion available in EF Core libraries 4.5 and EF 5.0 are enums mapped to integers but that is only tip of the iceberg. There is whole big feature behind - simple type mapping or conversions defined directly in mapping.

For example what if my database contains char column with Y, N values and I want to map it to bool property directly without any additional stuff doing the conversion inside my entity? Or more complex example - what if my column contains value like en-us and I want to map it to instance of CultureInfo? There are so many examples which can fit into this feature ...

Feature like enum mapping scales EF mapping features by inches. Ability to define custom conversion or simple type mapping scales EF mapping features by miles.

1,364 votes
Sign in
Password icon
Signed in as (Sign out)

We’ll send you updates on this idea

Ladislav Mrnka shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Password icon
Signed in as (Sign out)
  • AdminDiego Vega (Program Manager, Microsoft Entity Framework) commented  ·   ·  Flag as inappropriate

    @Tyson, we don't intend to build any more features of this magnitude into EF6. We would rather spent the effort of the team on improving EF Core (yes, to continue closing the functionality gap, among other goals). In theory, if someone from the community decided to contribute something like this for EF6, they could try, but the extensive work on validating the feature and the risk for the redesign makes it very unlikely.

  • Tyson commented  ·   ·  Flag as inappropriate

    Umm... did this get moved from EF6 to EFCore?
    What about this feature for EF6?
    Given EFCore is still no where near feature parity with EF6 we can not migrate to EFCore, so we are still desperately waiting for this feature in EF6...

  • Anonymous commented  ·   ·  Flag as inappropriate

    Guys, it is really important feature. Please implement it. Or We will celebrate 4 years in February?

  • Mikkel Lund commented  ·   ·  Flag as inappropriate

    Is this coming to EF6? We really need an easy way to work with NodaTime in legacy databases.

  • Dirk Watkins commented  ·   ·  Flag as inappropriate

    Enum to a lookup DB table please, with a nice display name column based on the Description attribute.

  • Søren commented  ·   ·  Flag as inappropriate

    Arh, finally some light at the end of the tunnel! NodaTime will be much easier to use. TimeSpan >24h duration can be solved. Proper domain models can be based directly on entity classes without sacrificing clarity. Custom value types can be used directly in entity classes. The world will be a better place when issue 242 finally gets resolved :)

  • Misiu commented  ·   ·  Flag as inappropriate

    @Diego any updates? As @Dan mentioned I'd also would be happy to have this as a build-in feature.

  • Dan M commented  ·   ·  Flag as inappropriate

    @Diego Vega, can you update us on the progress of this? We've passed the 4-year anniversary of this request, which is now the 3rd most popular on UserVoice. Not having this feature is causing a lot of pain. I hope this has finally become a priority for your team. Thank you!

  • Aron Tsang commented  ·   ·  Flag as inappropriate

    I hope you reconsider your stance on this feature. As it stands OData4/EF is broken. The OData team are pushing for usage of Microsoft.OData.Edm.Library.Date (whilst dropping support for DateTime) whilst your team are quite frankly refusing to support deserialization of DbDate to anything except DateTime.
    It seems like your two teams are giving conflicting response, when the OData project lives and dies on EF support.

  • Paul Lee commented  ·   ·  Flag as inappropriate

    I just can not understand, this should be a quick and easy update to EF and yet 4 years has passed and this is still not being selected for development.

    A clear explanations to why this is such a mission impossible for the development team is also missing.


  • Mark Junker commented  ·   ·  Flag as inappropriate

    I'd really like to see a full featured type conversion API like the one from NHibernate which is just done right.

  • Nathan Alden, Sr. commented  ·   ·  Flag as inappropriate

    A feature to map enums to and from strings in the database is very important when dealing with PostgreSQL custom enum types, which may be represented as strings.

  • Zackary Geers commented  ·   ·  Flag as inappropriate

    This is a major feature for several database designs I've worked with, I'd really love to see this back in the queue. It will provide a lot more flexibility in working with legacy databases, and improve the ability to transition from other products onto EF.

  • Neil commented  ·   ·  Flag as inappropriate

    Terrible, absolutely terrible, that an enterprise engine like entity framework doesn't support basic unsigned data types. Just awful, pathetic.

← Previous 1 3 4

Feedback and Knowledge Base