{
  "id": "dotnet/ef-core-navigation-property-not-mapped",
  "signature": "System.InvalidOperationException: The navigation property 'X' is not a mapped entity type. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the parameter values.",
  "signature_zh": "System.InvalidOperationException：导航属性 'X' 不是映射的实体类型。考虑使用 'DbContextOptionsBuilder.EnableSensitiveDataLogging' 来查看参数值。",
  "regex": "System\\.InvalidOperationException: The navigation property '[^']+' is not a mapped entity type",
  "domain": "dotnet",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Entity Framework Core attempts to include a navigation property that is not registered as a DbSet or has missing foreign key configuration.",
  "root_cause_type": "generic",
  "root_cause_zh": "Entity Framework Core 尝试包含一个未注册为 DbSet 或缺少外键配置的导航属性。",
  "versions": [
    {
      "version": "EF Core 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "EF Core 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "EF Core 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This removes the navigation property entirely, breaking the relationship query.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Does not address the missing mapping; EF Core still cannot resolve the navigation.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the navigation property's target entity is included in the DbContext as a DbSet. For example: public DbSet<Order> Orders { get; set; }",
      "success_rate": 0.9,
      "how": "Ensure the navigation property's target entity is included in the DbContext as a DbSet. For example: public DbSet<Order> Orders { get; set; }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add fluent API configuration in OnModelCreating: modelBuilder.Entity<Parent>().HasMany(p => p.Children).WithOne(c => c.Parent).HasForeignKey(c => c.ParentId);",
      "success_rate": 0.85,
      "how": "Add fluent API configuration in OnModelCreating: modelBuilder.Entity<Parent>().HasMany(p => p.Children).WithOne(c => c.Parent).HasForeignKey(c => c.ParentId);",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保导航属性的目标实体在 DbContext 中作为 DbSet 包含。例如：public DbSet<Order> Orders { get; set; }",
    "在 OnModelCreating 中添加流式 API 配置：modelBuilder.Entity<Parent>().HasMany(p => p.Children).WithOne(c => c.Parent).HasForeignKey(c => c.ParentId);"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/ef/core/querying/related-data",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-06-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}