Skip to content

Mechanism/API to specify a default conversion for any property of a given type in the model #10784

Description

@ajcvickers

Value conversions were introduced by #242. Currently conversions are only set per-property, although bulk configuration can be used at the end of OnModelCreating in the normal way. This issue is about adding some kind of mechanism to set the conversion for all properties of a given type in the model. This could be through configuration on the model, or it could be via improved bulk config APIs.

Activity

  1. added this to the Backlog milestone on Jan 27, 2018
  2. self-assigned this
    on Jan 27, 2018
  3. modified the milestones: Backlog, 3.0.0 on May 18, 2018
  4. ajcvickers commented on Jun 8, 2018

    @ajcvickers
    ContributorAuthor

    Note that the converter isn't really for "every property" even though it will also have that effect. It should also be for any time the CLR type is used in the query--that is, it is really a custom type mapping setup by the application.

  5. self-assigned this
    on Jun 11, 2018
  6. removed their assignment
    on Jul 31, 2018
  7. modified the milestones: 3.0.0, Backlog on Aug 3, 2018
  8. 72 remaining items

  9. vanillajonathan commented on Nov 23, 2021

    @vanillajonathan
    Contributor

    The value conversions article needs to be updated.

  10. Dynalon commented on Feb 10, 2022

    @Dynalon
    protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
    {
        configurationBuilder.Properties<string>().HaveConversion<byte[]>()
    }

    As @vanillajonathan outlined, this really should go into the value conversions article for documentation purposes. The only mention to that addition I could find was the 6.0.0-preview6 release blog article, and it took me a while to find it - even so it is perfectly what I needed.

  11. roji commented on Feb 10, 2022

    @roji
    Member

    @Dynalon @vanillajonathan I've added a bulk configuration section to the value conversions page in dotnet/EntityFramework.Docs#3716.

  12. thomaslevesque commented on Feb 10, 2022

    @thomaslevesque
    Member

    @Dynalon @vanillajonathan I've added a bulk configuration section to the value conversions page in #3716.

    Wrong link? #3716 doesn't seem to be related to this..

  13. roji commented on Feb 10, 2022

    @roji
    Member

    Sorry, wrong repo - corrected above.

  14. ronnyek commented on Feb 16, 2022

    @ronnyek

    Is there a decent workaround for efcore versions < 6? We dont have the ability to upgrade to .net 6 just yet, and have a domain model of thousands of tables that have used the old oracle convention of using bool as char(1) with constraints to Y/N. Something a value converter exists for, but is gonna make mapping this entities a royal nightmare.

  15. roji commented on Feb 17, 2022

    @roji
    Member

    @ronnyek take a look at Bulk configuration in OnModelCreating, that may work for you. Note also that EF Core 5.0 goes out of support in May, and 3.1 in December - so I'd recommend upgrading soon instead.

  16. igbenic commented on Nov 18, 2022

    @igbenic
  17. igbenic commented on Nov 18, 2022

    @igbenic
  18. added theissue type on Jun 15, 2025
  19. marked Global value converters #12303 as a duplicate of this issue on Jun 16, 2025
  20. roji commented on Feb 15, 2026

    @roji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions