How can I save a collection of CultureInfo type using EF Core without adding backing fields?

Joseph Gregory 0 Reputation points
2024-07-04T01:15:48.8333333+00:00

In a class, I have a collection of type List<CultureInfo> OfficialLanguages. I need to respect domain driven design for this project. I cannot add a backing field of type List<string> officialLanguagesCodes and handle it that way.

When I have a single property like User.Culture, I can handle a conversion like this in my OnModelCreating:

modelBuilder.Entity<User>().Property(u => u.Culture).HasConversion(c => c.Name, s => new(s));

How can I achieve something similar for a collection?

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
719 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more