# System.InvalidOperationException: The navigation property 'X' is not a mapped entity type. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the parameter values.

- **ID:** `dotnet/ef-core-navigation-property-not-mapped`
- **Domain:** dotnet
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Entity Framework Core attempts to include a navigation property that is not registered as a DbSet or has missing foreign key configuration.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| EF Core 6.0 | active | — | — |
| EF Core 7.0 | active | — | — |
| EF Core 8.0 | active | — | — |

## Workarounds

1. **Ensure the navigation property's target entity is included in the DbContext as a DbSet. For example: public DbSet<Order> Orders { get; set; }** (90% success)
   ```
   Ensure the navigation property's target entity is included in the DbContext as a DbSet. For example: public DbSet<Order> Orders { get; set; }
   ```
2. **Add fluent API configuration in OnModelCreating: modelBuilder.Entity<Parent>().HasMany(p => p.Children).WithOne(c => c.Parent).HasForeignKey(c => c.ParentId);** (85% success)
   ```
   Add fluent API configuration in OnModelCreating: modelBuilder.Entity<Parent>().HasMany(p => p.Children).WithOne(c => c.Parent).HasForeignKey(c => c.ParentId);
   ```

## Dead Ends

- **** — This removes the navigation property entirely, breaking the relationship query. (70% fail)
- **** — Does not address the missing mapping; EF Core still cannot resolve the navigation. (80% fail)
