'My EF Core 6 OData endpoint is returning whole infrastructure instead of model?

My EF Core application is returning what I imagine is context information in response instead of model. When calling the endpoint with expand option. This is the result returned:

{
"$id": "1",
"instance": null,
"container": {
  "$id": "2",
  "name": "SurveyQuestionValidations",
  "value": null,
  "next0": {
    "$id": "3",
    "name": "Id",
    "value": 1,
    "autoSelected": true
  },
  "autoSelected": false
},
"model": {
  "$id": "4",
  "schemaElements": [
    {
      "$id": "5",
      "declaredKey": [
        {
          "$id": "6",
          "defaultValueString": null,
          "propertyKind": 1,
          "type": {
            "isNullable": false,
            "definition": {
              "$id": "7",
              "name": "Int32",
              "namespace": "Edm",
              "typeKind": 1,
              "primitiveKind": 9,
              "schemaElementKind": 1,
              "fullName": "Edm.Int32"
            }
          },
          "declaringType": {
            "$ref": "5"
          },
          "name": "Id"
        }
      ],
      "schemaElementKind": 1,
      "namespace": "Data.Models",
      "name": "SurveyQuestion",
      "fullName": "Data.ModelsSurveyQuestion",
      "typeKind": 2,
      "hasStream": false,
      "isAbstract": false,
      "isOpen": false,
      "declaredProperties": [ ...etc   

This only happens when using expand. And the query is really slow but I believe it is related.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source