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.
- is fixed by
-
EF-285 CamelCaseElementNameConvention clash with type discriminator "_t"
-
- Closed
-