Skip to content

The type mapping for 'Dictionary<string, string>' has not implemented code literal generation. #1318

Closed as duplicate

Description

@mijgame

Hi,

I have a model as follows:

    public class JobDefinition
    {
        [Required]
        public Guid JobDefinitionId { get; set; }
        
        [Required]
        public int Version { get; set; }
        
        [Required]
        public Guid TenantId { get; set; }
        
        [Required]
        public JobType JobType { get; set; }
                
        [Required]
        public string ActionType { get; set; }
        
        [Required]
        [Column(TypeName="jsob")]
        public Dictionary<string, string> Properties { get; set; }
            
        // Refers to another entity
        public List<ScheduleJobDefinitions> ScheduleJobDefinitions { get; set; }
    }

If I understand correctly, this should work and convert the dictionary to a json object.
When generating the migration using dotnet ef migrations add DbInitial -o Database/Migrations, the program builds but then gives the following error:
The type mapping for 'Dictionary<string, string>' has not implemented code literal generation.

What could be going on? I have also tried [Column(TypeName="hstore")], but that didn't make a difference unfortunately.

I use .NET Core 3.1.2 with Entity Framework Core.

Thanks in advance.

Activity

  1. roji commented on Mar 26, 2020

    @roji
    Member

    You're probably trying to seed hstore data (with the HasData API). Unfortunately that's not possible currently - I'll keep this open and will try to look into it at some point.

  2. added this to the Backlog milestone on Mar 26, 2020
  3. mijgame commented on Mar 26, 2020

    @mijgame
    Author

    That is exactly what is happening; thanks for pointing me into the right direction!

  4. modified the milestones: Backlog, 7.0.0 on Jul 9, 2022
  5. roji commented on Jul 9, 2022

    @roji
    Member

    This should be unblocked by dotnet/efcore#28330, implement this mainly to verify that.

  6. modified the milestones: 7.0.0, 8.0.0 on Oct 15, 2022
  7. modified the milestones: 8.0.0, Backlog on Nov 13, 2023
  8. added theissue type on Jun 14, 2025
  9. roji commented on Oct 21, 2026

    @roji
    Member

    AI Triage

    The below is an AI-generated analysis and may contain inaccuracies.

    This is the missing hstore seed-data scaffolding feature identified in the discussion, rather than a general JSON dictionary issue. The existing Feature classification is appropriate.

    Verified on current main that HasData with an hstore-mapped Dictionary<string, string> successfully generates both the migration and model snapshot. Coverage includes populated and empty dictionaries, null dictionary values, and strings containing quotes, backslashes, and newlines. No provider code change is needed for this scenario: EF Core 7.0 added dictionary literal generation in dotnet/efcore#28330, addressing the prerequisite described above.

    The related upstream collection-literal issue is dotnet/efcore#19274; no additional matching upstream issue was found. I am adding focused provider regression coverage to verify the original scenario, as requested in the maintainer comment.

    This does not add arbitrary JSON dictionary support or hstore query translations. SQL literal generation is separate work tracked by #3780 and is not changed here.

  10. roji commented on Oct 21, 2026

    @roji
    Member

    Closing as per the above - everything already works since EF 7 thanks to dotnet/efcore#28330.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions