You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AddJsonApi: Only register IoC services when not already provided
This makes app setup easier. Previously, you often had to register overrides *after* calling AddJsonApi (last one wins). With this change, order does not matter anymore. Note that the order of MVC filters still matters, it is unrelated to this change.
Copy file name to clipboardExpand all lines: docs/usage/common-pitfalls.md
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -87,11 +87,13 @@ Neither sounds very compelling. If stored procedures is what you need, you're be
87
87
Although recommended by Microsoft for hard-written controllers, the opinionated behavior of [`[ApiController]`](https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-7.0#apicontroller-attribute) violates the JSON:API specification.
88
88
Despite JsonApiDotNetCore trying its best to deal with it, the experience won't be as good as leaving it out.
Registering your own services in the IoC container afterwards increases the chances that your replacements will take effect.
92
-
Also, register with `services.AddResourceDefinition/AddResourceService/AddResourceRepository()` instead of `services.AddScoped()`.
90
+
#### Register/override injectable services
91
+
Register your JSON:API resource services, resource definitions and repositories with `services.AddResourceService/AddResourceDefinition/AddResourceRepository()` instead of `services.AddScoped()`.
93
92
When using [Auto-discovery](~/usage/resource-graph.md#auto-discovery), you don't need to register these at all.
94
93
94
+
> [!NOTE]
95
+
> In older versions of JsonApiDotNetCore, registering your own services in the IoC container *afterwards* increased the chances that your replacements would take effect.
96
+
95
97
#### Never use the Entity Framework Core In-Memory Database Provider
96
98
When using this provider, many invalid mappings go unnoticed, leading to strange errors or wrong behavior. A real SQL engine fails to create the schema when mappings are invalid.
97
99
If you're in need of a quick setup, use [SQLite](https://www.sqlite.org/). After adding its [NuGet package](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Sqlite), it's as simple as:
Copy file name to clipboardExpand all lines: test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ public AtomicCreateResourceWithClientGeneratedIdTests(IntegrationTestContext<Tes
24
24
// These routes need to be registered in ASP.NET for rendering links to resource/relationship endpoints.
Copy file name to clipboardExpand all lines: test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Links/AtomicRelativeLinksWithNamespaceTests.cs
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ public AtomicRelativeLinksWithNamespaceTests(
0 commit comments