CamelCaseElementNameConvention overrides "_t" for type discriminator

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Unknown
    • 8.4.0, 9.1.0, 10.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      When doing something like:

       

      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          ArgumentNullException.ThrowIfNull(modelBuilder);
          base.OnModelCreating(modelBuilder);
          // Setup polymorphism
          modelBuilder.Entity<Tournament>()
              .HasDiscriminator()
              .HasValue<BasketballTournament>(nameof(BasketballTournament));
          // Setup collection naming
          modelBuilder.Entity<Tournament>().ToCollection("Tournaments");
          modelBuilder.Entity<Team>().ToCollection("Teams");
          modelBuilder.Entity<Entry>().ToCollection("Entries");
      }
      

      The document gets serialized something like:
       

      {
      "_id":"test-tournament",
      "entryCutoffDate": ISODate("2024-03-21T16:15:00.000+0000"),
      "name":"Test Tournament 2024 - Men's",
      "year": NumberInt(2024),
      "discriminator":"BasketballTournament"
      }
      

      Ideally, they'd get serialized with an "_t" field instead of the "discriminator" field to match the polymorphism of the default MongoDB driver. I tried to do this several ways but failed.

       

            Assignee:
            Damien Guard
            Reporter:
            Andrew Kuntz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: