Uploaded image for project: 'Entity Framework'
  1. Entity Framework
  2. EF-99

Querying embedded documents throws ArgumentException: TransparentIdentifier Inner is not defined

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • None
    • Dotnet Drivers

      I have a simple Person }}class with an array of {{{}Addresses:

       
      public class Person
      {{{}}
        public Guid Id { get; set; }  
      {{  public string? FirstName { get; set; }}}
      {{  public string? LastName { get; set; }}}
      {{  public IEnumerable<Address>? Addresses { get; set; }}}
      }

      public class Address
      {{{}}
      {{  public string? Street { get; set; }}}
      {{  public string? City { get; set; }}}
      {{  public string? ZipCode { get; set; }}}
      }
      I've mapped the entities as so:

      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {{{}}
        modelBuilder
          .Entity<Person>()
          .ToCollection("Person")
          .OwnsMany(x => x.Addresses);
      }
      I successfully write data out using EF:

      {{{}}
        "_id": {
          "$binary": {
            "base64": "CbUTuW9pXkC3Vlmkesu1Fg==",
            "subType": "03"
      {{    }}}
        },
        "FirstName": "Bob",
        "LastName": "Smith",
        "Addresses": [
          {
            "City": "Denver",
            "Street": "123 Main St.",
            "ZipCode": "80401"
          },
          {
            "City": "Los Angeles",
            "Street": "246 Beach Dr.",
            "ZipCode": "90210"
      {{    }}}
        ]
      }

      When I try a simple query:

       
      public IQueryable<Address> GetPersonData()
      {{{    }}
        var data = _dbContext?.Person.SelectMany(x => x.Addresses).Take(10);
          return data;
      }
      The follow exception is thrown:

      System.ArgumentException: Field 'Microsoft.EntityFrameworkCore.Query.TransparentIdentifierFactory+TransparentIdentifier`2[db_editor_api.Models.Person,db_editor_api.Models.Address].Inner' is not defined for type 'db_editor_api.Models.Person'

       

      This is as simple an operation as we can get in terms of working with embedded documents and should work seamlessly.

            Assignee:
            damien.guard@mongodb.com Damien Guard
            Reporter:
            tonyhernandez743@gmail.com Anthony Hernandez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: