# System.InvalidOperationException: Cannot create a DbSet for 'X' because a DbSet with the same entity type already exists.

- **ID:** `dotnet/ef-core-multiple-navigation-sets`
- **Domain:** dotnet
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The DbContext class defines two or more DbSet properties that map to the same entity type, causing ambiguity in EF Core's internal model building.

## Version Compatibility

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

## Workarounds

1. **Remove the duplicate DbSet property from the DbContext class. Keep only one declaration for the entity type. For example, remove either 'public DbSet<Order> Orders { get; set; }' or 'public DbSet<Order> SalesOrders { get; set; }'.** (95% success)
   ```
   Remove the duplicate DbSet property from the DbContext class. Keep only one declaration for the entity type. For example, remove either 'public DbSet<Order> Orders { get; set; }' or 'public DbSet<Order> SalesOrders { get; set; }'.
   ```
2. **If you need multiple query surfaces, use separate DbContext classes for different bounded contexts.** (80% success)
   ```
   If you need multiple query surfaces, use separate DbContext classes for different bounded contexts.
   ```

## Dead Ends

- **** — This removes the property from the context entirely, losing the ability to query that entity through that property. (70% fail)
- **** — This duplicates code and does not solve the core issue of duplicate DbSet definitions. (50% fail)
