CollectionMapper.RavenDB.NetCore 7.0.1

dotnet add package CollectionMapper.RavenDB.NetCore --version 7.0.1
                    
NuGet\Install-Package CollectionMapper.RavenDB.NetCore -Version 7.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CollectionMapper.RavenDB.NetCore" Version="7.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CollectionMapper.RavenDB.NetCore" Version="7.0.1" />
                    
Directory.Packages.props
<PackageReference Include="CollectionMapper.RavenDB.NetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CollectionMapper.RavenDB.NetCore --version 7.0.1
                    
#r "nuget: CollectionMapper.RavenDB.NetCore, 7.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CollectionMapper.RavenDB.NetCore@7.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CollectionMapper.RavenDB.NetCore&version=7.0.1
                    
Install as a Cake Addin
#tool nuget:?package=CollectionMapper.RavenDB.NetCore&version=7.0.1
                    
Install as a Cake Tool

CollectionMapper.RavenDB.NetCore

Map your C# types to custom RavenDB collection names — without touching DocumentStore configuration by hand for every entity.

Installation

dotnet add package CollectionMapper.RavenDB.NetCore

Quick start

Wire the mapper into your DocumentStore once, then register your types using any combination of the three approaches below.

using CollectionMapper.RavenDB;
using Raven.Client.Documents;

// 1. Register your mappings and [decorators] (see options below)
RavenDBMapperConventions.RegisterByAssembly<MyEntity>();

// 2. Assign to the store conventions
IDocumentStore store = new DocumentStore
{
    Urls = ["http://localhost:8080"],
    Database = "MyDatabase",
    Conventions =
    {
        FindCollectionName = RavenDBMapperConventions.FindCollection,
    }
}.Initialize();

Any type that is not explicitly mapped falls back to RavenDB's default naming convention.


Registration options

1. Fluent mapper

Use RavenDBCollectionMapper when you want to keep mapping configuration in one place, separate from your entity classes.

var mapper = new RavenDBCollectionMapper();
mapper.Map<User>("MasterUsers")
      .Map<Order>("CustomOrders")
      .Map<Invoice>("Invs");

RavenDBMapperConventions.RegisterMapper(mapper);

Registering the same type twice keeps the last name (Map is last-write-wins).

Auto-discovered mapper class

Subclass RavenDBCollectionMapper and it will be picked up automatically by RegisterByAssembly / RegisterByAssemblies — no manual call to RegisterMapper needed.

public class MyCollectionMapper : RavenDBCollectionMapper
{
    public MyCollectionMapper()
    {
        Map<User>("MasterUsers");
        Map<Order>("CustomOrders");
        Map<Invoice>("Invs");
    }
}

2. [RavenCollection] attribute

Decorate the class directly when you prefer co-location.

using CollectionMapper.RavenDB.Attributes;

[RavenCollection("MyAccounts")]
public class Account
{
    public string Id { get; set; }
    public string Name { get; set; }
}

[RavenCollection("SuperUsers")]
public class User
{
    public string Id { get; set; }
    public string Name { get; set; }
}

Then scan the assembly that contains those classes:

RavenDBMapperConventions.RegisterByAssembly<Account>();

3. [RavenCollectionAssignedFrom<T>] attribute

Assign a derived type to the same collection as its base type. Useful for polymorphic hierarchies stored in a single collection.

using CollectionMapper.RavenDB.Attributes;

public class Fruit { }

[RavenCollectionAssignedFrom<Fruit>]
public class Banana : Fruit { }

[RavenCollectionAssignedFrom<Fruit>]
public class Strawberry : Fruit { }

Banana and Strawberry documents are stored in the Fruits collection, alongside Fruit documents.


Assembly scanning

Scan one assembly (the one that contains T):

RavenDBMapperConventions.RegisterByAssembly<MyEntity>();

Scan multiple assemblies at once:

RavenDBMapperConventions.RegisterByAssemblies(
    typeof(MyEntity).Assembly,
    typeof(AnotherEntity).Assembly
);

Assembly scanning discovers both [RavenCollection] and [RavenCollectionAssignedFrom<T>] attributes, as well as any RavenDBCollectionMapper subclasses defined in those assemblies.


Debug mode

Enable verbose logging to Console and System.Diagnostics.Trace to see every registration and every collection lookup:

RavenDBMapperConventions.EnableDebugMode();

Example output:

[CollectionMapper.RavenDB] ::Register:: MyApp.Entities.Fruit → "Fruits" | source: [RavenCollection]
[CollectionMapper.RavenDB] ::Register:: MyApp.Entities.Banana → "Fruits" | source: [RavenCollectionAssignedFrom<Fruit>]
[CollectionMapper.RavenDB] ::FindCollection:: MyApp.Entities.Banana → "Fruits"
[CollectionMapper.RavenDB] ::FindCollection:: MyApp.Entities.Unmapped → "Unmappeds" (fallback)

Call EnableDebugMode() before registration calls to capture those log lines too.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.0.1 522 5/12/2026
7.0.0 75 5/12/2026
6.0.1 1,457 1/30/2024
5.4.100 516 9/30/2023
5.0.1 3,889 1/30/2021
5.0.0 1,318 1/30/2021