@@ -31,7 +31,8 @@ The following steps describe how to create a JSON:API project with MongoDB.
31311 . Configure MongoDB and JsonApiDotNetCore in ` Program.cs ` , seeding the database with sample data:
3232 ``` c#
3333 var builder = WebApplication .CreateBuilder (args );
34- builder .Services .AddSingleton (_ => new MongoClient (" mongodb://localhost:27017" ).GetDatabase (" ExampleDbName" ));
34+ builder .Services .AddSingleton (_ =>
35+ new MongoClient (" mongodb://localhost:27017" ).GetDatabase (" ExampleDbName" ));
3536 builder .Services .AddJsonApi (options =>
3637 {
3738 options .UseRelativeLinks = true ;
@@ -74,19 +75,6 @@ The following steps describe how to create a JSON:API project with MongoDB.
7475 }
7576 ```
7677
77- > [ !TIP]
78- > If your API project uses MongoDB only (so not in combination with EF Core), then instead of
79- > registering all MongoDB resources and repositories individually, you can use:
80- >
81- > ``` c#
82- > builder .Services .AddJsonApi (facade => facade .AddCurrentAssembly ());
83- > builder .Services .AddJsonApiMongoDb ();
84- >
85- > builder .Services .AddScoped (typeof (IResourceReadRepository <,>), typeof (MongoRepository <,>));
86- > builder .Services .AddScoped (typeof (IResourceWriteRepository <,>), typeof (MongoRepository <,>));
87- > builder .Services .AddScoped (typeof (IResourceRepository <,>), typeof (MongoRepository <,>));
88- > ```
89-
90781 . Start your API
9179 ``` bash
9280 dotnet run
@@ -137,6 +125,19 @@ The following steps describe how to create a JSON:API project with MongoDB.
137125
138126</details >
139127
128+ > [ !TIP]
129+ > If your API project uses MongoDB only (so not in combination with EF Core), then instead of
130+ > registering all MongoDB resources and repositories individually, you can use:
131+ >
132+ > ``` c#
133+ > builder .Services .AddJsonApi (facade => facade .AddCurrentAssembly ());
134+ > builder .Services .AddJsonApiMongoDb ();
135+ >
136+ > builder .Services .AddScoped (typeof (IResourceReadRepository <,>), typeof (MongoRepository <,>));
137+ > builder .Services .AddScoped (typeof (IResourceWriteRepository <,>), typeof (MongoRepository <,>));
138+ > builder .Services .AddScoped (typeof (IResourceRepository <,>), typeof (MongoRepository <,>));
139+ > ```
140+
140141## Using client-generated IDs
141142
142143Resources that inherit from `HexStringMongoIdentifiable ` use auto - generated (high - performance ) 12 - byte hexadecimal
0 commit comments