---
title: "RVN005 - Multi-map index has no AddMap call in any constructor"
description: "RVN005* reports multi-map index classes that have no AddMap or AddMapForAll calls reachable from a constructor."
url: "https://docs.ravendb.net/7.2/client-api/csharp-code-analyzers/RVN005"
version: "7.2"
---

# RVN005 - Multi-map index has no AddMap call in any constructor

> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - **RVN005** reports multi-map index classes that have no `AddMap` or `AddMapForAll` calls reachable from a constructor.
>
> - **Default severity**: *Info*  
>   **Automated code fix**: *No*
>
> - In this article:
>   - [Description](#description)
>   - [Trigger condition](#trigger-condition)
>     - [When is RVN005 reported?](#when-is-rvn005-reported)
>     - [When is RVN005 not reported?](#when-is-rvn005-not-reported)
>   - [How to resolve](#how-to-resolve)
>     - [Before (triggers RVN005)](#before-triggers-rvn005)
>     - [After (correct)](#after-correct)
>   - [Limitations](#limitations)
>   - [Related C# analyzers](#related-c-analyzers)

## Description {#description}

Every non-abstract class that derives from `AbstractMultiMapIndexCreationTask`
(or the time-series and counters variants: `AbstractMultiMapTimeSeriesIndexCreationTask`, `AbstractMultiMapCountersIndexCreationTask`)
and uses the standard `CreateIndexDefinition()` implementation must register at least one map with `AddMap` or `AddMapForAll` before the index definition is built.

**Deployment failure**:  
Without a map, the client throws `ArgumentNullException` while preparing the deployment request, before sending it to the server.
The exception identifies the parameter as `Index definitions contains no Maps` and does not name the index.

**Batch deployment**:  
When indexes are deployed together through `IndexCreation.CreateIndexes()` or `store.ExecuteIndexes()`,
an index with no maps prevents every index in that batch from being deployed.

## Trigger condition {#trigger-condition}

### When is RVN005 reported?

- RVN005 is reported on the class name when no `AddMap` or `AddMapForAll` call is reachable from any constructor of the index class or its base classes,
  including a base class from a referenced project.

- RVN005 is still reported when maps are registered only in a method that is not reachable from a constructor,
  even if that method runs before the index definition is built.

### When is RVN005 not reported?

A call found in any constructor of the index class or its base classes is enough to suppress RVN005.
Calls in methods of those classes also count when a constructor calls the method, directly or through other methods.  
See [Limitations](#limitations) for cases where a call counts even though it may not execute.

RVN005 is also not reported for the following index classes, even when no `AddMap` or `AddMapForAll` call is found:

- Abstract index classes. Their subclasses are checked instead.
- Indexes that override `CreateIndexDefinition()`.
- Single-map time-series and counters indexes (`AbstractTimeSeriesIndexCreationTask` and `AbstractCountersIndexCreationTask`).
  Neither RVN004 nor RVN005 checks them.
- Index classes that are `private`, `protected`, or `private protected`, or nested in a class with one of these access levels.
- Indexes whose required base-class information cannot be obtained from generated metadata or available source.
  This can happen when a base class is in a compiled assembly built with a client version that does not include the RavenDB analyzers.
  See [Distribution](https://docs.ravendb.net/7.2/client-api/csharp-code-analyzers/overview.md#distribution).

## How to resolve {#how-to-resolve}

Add a constructor (or update the existing one) that calls `AddMap<TSource>(…)` for each document type the index should map.
Alternatively, use `AddMapForAll<TBase>(…)` to register maps for concrete types assignable to `TBase` in the assembly that defines `TBase`.

For time-series and counters multi-map indexes, use `AddMap<TSource>("<name>", …)` or `AddMapForAll<TBase>("<name>", …)`,
passing the time-series or counter name.

---

### Before (triggers RVN005)

```csharp
// Triggers RVN005: no AddMap or AddMapForAll call.
public class Animals_ByName : AbstractMultiMapIndexCreationTask
{
}
```

### After (correct)

```csharp
public class Animals_ByName : AbstractMultiMapIndexCreationTask
{
    public Animals_ByName()
    {
        AddMap<Cat>(cats => from c in cats select new { c.Name });
        AddMap<Dog>(dogs => from d in dogs select new { d.Name });
    }
}
```

## Limitations {#limitations}

RVN005 does not verify that every constructor or execution path registers a map.

**RVN005 can be suppressed even when no maps are registered at runtime:**

- A call in any constructor counts, including a base constructor that the index never calls.
- A call inside a condition or loop counts even when the condition prevents it from executing or the loop runs zero times.
- A call inside a lambda or local function nested in a checked constructor or method counts even if the lambda or local function is never invoked.
- Calls to helper methods are matched by name only. A registration in another overload with the same name can therefore suppress RVN005 even when that overload is never called.
- An `AddMapForAll` call counts even if it finds no eligible concrete types and registers no maps.

**RVN005 can be reported even when maps are registered at runtime:**

- A registration made only in a property setter is not detected, even if a constructor sets that property.
- A registration made only in a helper invoked through a delegate, such as `Action configure = Configure; configure();`, is not detected.
- A helper method defined in a base class from a referenced project is not followed when only a derived constructor calls it.
  `AddMap` or `AddMapForAll` calls reachable from that base class's own constructors still count through its generated index metadata.

## Related C# analyzers {#related-c-analyzers}

- [RVN004](https://docs.ravendb.net/7.2/client-api/csharp-code-analyzers/RVN004.md)  
  Equivalent rule for regular single-map indexes.

- [RVN006](https://docs.ravendb.net/7.2/client-api/csharp-code-analyzers/RVN006.md)  
  Suggests a regular index when only one `AddMap` call is found.  
  Calls inside loops and indexes using `AddMapForAll` are excluded.

## See also

- [C# code analyzers overview](https://docs.ravendb.net/7.2/client-api/csharp-code-analyzers/overview.md)
- [Multi-map indexes](https://docs.ravendb.net/7.2/indexes/multi-map-indexes.md)
- [Creating and deploying indexes](https://docs.ravendb.net/7.2/indexes/creating-and-deploying.md)
- [Indexing time series](https://docs.ravendb.net/7.2/document-extensions/timeseries/indexing.md)
- [Indexing counters](https://docs.ravendb.net/7.2/document-extensions/counters/indexing.md)
